@param GenericEvent $event

@throws UnexpectedTypeException
558445
public function sendUserRegistrationEmail(GenericEvent $event)
    {
        if ($this->systemSettingContext->get('security.user_verification')) {
            return;
        }

        $user = $event->getSubject();

        Assert::isInstanceOf($user, WebUserInterface::class);

        $this->emailSender->send(Emails::USER_REGISTRATION, [$user->getEmail()], ['user' => $user]);
    }
149486
public function setStructureTypeToParent(PersistEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof ArticlePageDocument
            || LocalizationState::GHOST === $this->documentInspector->getLocalizationState($document->getParent())
            || $document->getStructureType() === $document->getParent()->getStructureType()
        ) {
            return;
        }

        $document->getParent()->setStructureType($document->getStructureType());
        $this->documentManager->persist($document->getParent(), $event->getLocale());
    }
849617
public function onResourcesDelete(GenericDatasEvent $event)
    {
        $resources = $event->getDatas();
        $ids = array();

        foreach ($resources as $resource) {
            $ids[] = $resource->getId();
        }
        $this->tagManager->removeTaggedObjectsByClassAndIds(
            'Claroline\CoreBundle\Entity\Resource\ResourceNode',
            $ids
        );
    }
938044
@SuppressWarnings("unchecked") // cast to generic Map will always be okay in this case
    private void validateEventValue(Object value, int depth) {
        if (value instanceof String) {
            String strValue = (String) value;
            if (strValue.length() >= 10000) {
                throw new InvalidEventException("An event cannot contain a string property value longer than 10," +
                        "000 characters.");
            }
        } else if (value instanceof Map) {
            validateEvent((Map<String, Object>) value, depth + 1);
        } else if (value instanceof Iterable) {
            for (Object listElement : (Iterable) value) {
                validateEventValue(listElement, depth);
            }
        }
    }
244466
private void setEventType(short eventType) {
      if (eventType != ADDED && eventType != REMOVED && eventType != CHANGED) {
         throw new IllegalArgumentException("Invalid eventType code "
            + eventType);
      }

      this.eventType = eventType;
   }
1317418
public function onChannelPreDelete(ResourceControllerEvent $event): void
    {
        $channel = $event->getSubject();

        if (!$channel instanceof ChannelInterface) {
            throw new UnexpectedTypeException(
                $channel,
                ChannelInterface::class
            );
        }

        $results = $this->channelRepository->findBy(['enabled' => true]);

        if (!$results || (count($results) === 1 && current($results) === $channel)) {
            $event->stop('sylius.channel.delete_error');
        }
    }
594283
public function onExecuteMessageTask(GenericDataEvent $event)
    {
        /** @var ScheduledTask $task */
        $task = $event->getData();
        $data = $task->getData();
        $users = $task->getUsers();
        $object = isset($data['object']) ? $data['object'] : null;
        $content = isset($data['content']) ? $data['content'] : null;

        if (!empty($users) && !empty($object) && !empty($content)) {
            $message = $this->messageManager->create($content, $object, $users);
            $this->messageManager->send($message);
            $this->taskManager->markAsExecuted($task);
        }

        $event->stopPropagation();
    }
1117863
public function registerCallback( $event, $callback ) {

		if ( !is_string( $event ) ) {
			throw new InvalidArgumentException( "Event is not a string" );
		}

		if ( !is_callable( $callback ) ) {
			throw new RuntimeException( "Invoked object is not a valid callback or Closure" );
		}

		$this->addToCollection( $event, new GenericCallbackEventListener( $callback ) );
	}
1139513
public function onObjectTag(GenericDataEvent $event)
    {
        $taggedObject = null;
        $data = $event->getData();

        if (is_array($data) && isset($data['tag']) && isset($data['object'])) {
            $user = isset($data['user']) ? $data['user'] : null;
            $taggedObject = $this->manager->tagObject($data['tag'], $data['object'], $user);
        }

        $event->setResponse($taggedObject);
    }
231295
protected function setGenericMessageHandler(GenericMessageHandler $handler): void
	{
		$handler->setBot($this);
		$this->genericMessageHandler = $handler;
	}
561483
public function onPostSerialize(ObjectEvent $event)
    {
        $object = $event->getObject();

        // FIXME This can be removed, as soon as we've got rid of all ApiEntities.
        if ($object instanceof ApiWrapper) {
            $object = $object->getEntity();
        }

        if (!$object instanceof AuditableInterface && !$object instanceof LocalizedAuditableBehavior) {
            return;
        }

        $visitor = $event->getVisitor();

        if (!$visitor instanceof GenericSerializationVisitor) {
            return;
        }

        $visitor->setData('_hash', $this->hasher->hash($object));
    }
221340
public function onRetrieveUsedTagsByClassAndIds(GenericDataEvent $event)
    {
        $tags = [];
        $data = $event->getData();

        if (is_array($data) && isset($data['class']) && !empty($data['ids'])) {
            /** @var TaggedObject[] $taggedObjects */
            $taggedObjects = $this->manager->getTaggedObjects($data['class'], $data['ids']);

            if (isset($data['frequency']) && $data['frequency']) {
                //array [tagName => frequency]
                foreach ($taggedObjects as $taggedObject) {
                    $tag = $taggedObject->getTag();
                    if (!array_key_exists($tag->getName(), $tags)) {
                        $tags[$tag->getName()] = 0;
                    }
                    ++$tags[$tag->getName()];
                }
            } else {
                //array [tagName]
                foreach ($taggedObjects as $taggedObject) {
                    $tag = $taggedObject->getTag();
                    $tags[$tag->getId()] = $taggedObject->getTag()->getName();
                }
                $tags = array_values($tags);
            }
        }
        $event->setResponse($tags);
    }
1089401
protected <E> void dispatchEvent(E event, Collection<Throwable> errors) {

    @SuppressWarnings({ "unchecked", "rawtypes" })
    Class<E> eventType = (Class) event.getClass();
    EventDispatcher<? super E> eventDispatcher = getEventDispatcherOptional(eventType);
    boolean dispatched = false;
    if (eventDispatcher != null) {
      dispatched = eventDispatcher.handleEvent(event, errors);
    }
    if (!dispatched) {
      handleUndispatchedEvent(event);
    }
  }
868913
public function publish(GenericEvent $event)
    {
        $legacyArticle = $event->getSubject();
        $arguments = $event->getArguments();

        if ($legacyArticle instanceof \Article) {
            $entry = $this->em
                ->getRepository('Newscoop\IngestPluginBundle\Entity\Feed\Entry')
                ->findOneByArticleId($legacyArticle->getArticleNumber());
            if ($entry !== null) {
                $entry->setPublished(new \DateTime($legacyArticle->getPublishDate()));
                $this->em->persist($entry);
                $this->em->flush();
            }
        }
    }
17971
public function dispatch($eventName, array $context = array())
    {
        return $this->getEventDispatcher()->dispatch(
            $eventName,
            new GenericEvent($this, $context)
        );
    }
986930
public function onReflectProgress(GenericEvent $event)
    {
        $context = $event->getArguments();
        $this->logger->info('Parsing file "{file}" in progress.', $context);
    }
128532
public function onNotification(GenericEvent $event, $eventName)
    {
        static $start = false;

        switch ($eventName) {
            case Events::PROGRESS:
                if (!$start) {
                    $this->stopwatch->start($event['source']);
                    $start = true;
                }
                return;
            case Events::ERROR:
                $message = 'Parser has detected an error on file "%filename%". %error%';
                break;
            case Events::COMPLETE:
                $message  = "Parsing data source \"%source%\" completed.";
                $appEvent = $this->stopwatch->stop($event['source']);
                $time     = $appEvent->getDuration();
                $memory   = $appEvent->getMemory();

                $event['profile'] = sprintf(
                    'Time: %s, Memory: %4.2fMb',
                    Timer::toTimeString($time),
                    $memory / (1024 * 1024)
                );
                break;
        }
        $format = $this->notifier->getMessageFormat();

        $event['eventname'] = $eventName;
        $event['message']   = strtr($message, $this->getPlaceholders($event));
        $event['formatted'] = strtr($format, $this->getPlaceholders($event));

        $this->notifier->notify($event);
    }