Apply given event

@param DomainEventInterface $event
516227
protected function apply(DomainEventInterface $event)
    {
        $handler = $this->determineEventHandlerMethodFor($event);

        if (!method_exists($this, $handler)) {
            return;
        }

        $this->{$handler}($event);
    }
1067220
public function onCreateConnection(HostEvent $event)
    {
        $connectionAdapter = $this->getConnectionAdapter($event->getHost());
        if ($connectionAdapter instanceof ConnectionAdapterInterface) {
            $event->getHost()->setConnection($connectionAdapter);
        }
    }
327793
public function initializeState(DomainEventStream $stream): void
    {
        foreach ($stream as $message) {
            ++$this->playhead;
            $this->handleRecursively($message->getPayload());
        }
    }
217337
protected function applyEventDeleted(EventDeleted $event)
    {
        $eventId = $event->getItemId();
        $this->repository->removeRelations($eventId);

    }
774271
protected function afterDispatch(string $eventName, $event)
    {
        $this->postDispatch($eventName, $event instanceof Event ? $event : new LegacyEventProxy($event));
    }
289407
protected function _insertBelongsToDataIntoEventFindResult($event)
    {
        $entity = $event->getSubject()->entity;
        $repository = $this->_controller()->loadModel();
        $associations = $repository->associations();

        foreach ($associations as $association) {
            $associationType = $association->type();
            $associationTable = $association->getTarget(); // Users

            // belongsTo and HasOne
            if ($associationType === Association::MANY_TO_ONE || $associationType === Association::ONE_TO_ONE) {
                $foreignKey = $association->getForeignKey(); // user_id
                $associationId = $entity->$foreignKey; // 1234

                if (!empty($associationId)) {
                    $associatedEntity = $associationTable->newEntity();
                    $associatedEntity->set('id', $associationId);

                    // generate key name required for neoMerx to find and use the entity data
                    // => ?!? => unfortunately, _propertyName is protected. We have got serious reason to use it though
                    $reflectedAssoc = new \ReflectionClass('Cake\ORM\Association');
                    $propertyNameProp = $reflectedAssoc->getProperty('_propertyName');
                    $propertyNameProp->setAccessible(true);
                    $key = $propertyNameProp->getValue($association);

                    if (!$key) {
                        $key = Inflector::singularize($association->getName()); // Users
                        $key = Inflector::underscore($key); // user
                    }

                    $entity->set($key, $associatedEntity);
                }
            }

            // insert the contained associations into the query
            if (!empty($event->getSubject()->query)) {
                $event->getSubject()->query->contain($association->getName());
            }
        }

        $event->getSubject()->entity = $entity;
    }
832258
public static function onFlushContent(Event $event)
    {
        $content = $event->getTarget();
        if (!($content instanceof AbstractClassContent)) {
            return;
        }

        $page = $content->getMainNode();
        if (null === $page) {
            return;
        }

        $newEvent = new Event($page, $content);
        $newEvent->setDispatcher($event->getDispatcher());
        self::onFlushPage($newEvent);
    }
529355
public function setCacheForEntity(EntityLoadEvent $event)
    {
        $entity = $event->getEntity();

        if (!$entity->isLoaded()) {
            $this->cache->set($entity);
            $this->dispatcher->dispatch('cache.set', new CacheEvent($entity));
        }
    }
422051
protected <T extends DomainEvent> T registerEvent(T event) {
        Assert.notNull(event, "Domain event must not be null!");

        this.domainEvents.add(event);
        return event;
    }
84127
public function addOrganizationSecurityIdentities(AddSecurityIdentityEvent $event): void
    {
        try {
            $sids = $event->getSecurityIdentities();
            $sids = IdentityUtils::merge(
                $sids,
                OrganizationSecurityIdentity::fromToken(
                    $event->getToken(),
                    $this->context,
                    $this->roleHierarchy
                )
            );
            $event->setSecurityIdentities($sids);
        } catch (\InvalidArgumentException $e) {
            // ignore
        }
    }
1253720
public function onPostUpdate(ResourceEventInterface $event)
    {
        $page = $this->getPageFromEvent($event);

        $this->deletePageCache($page);
    }
991839
public function dispatch(DomainEvents $events) : void {
        $events->each(function (DomainEvent $event) {
            $this->listeners->each(function (Listener $listener) use ($event) {
                    $listener->handle($event);
            });
        });
    }
711927
protected function setRedirecToLogin(Event $event)
    {
        $url = $this->router->generate('fos_user_security_login');
        $event->setResponse(new RedirectResponse($url));
    }
1215958
public function bindPluginEvents(Event $event)
    {
        foreach ($this->plugins as $field => $plugin) {
            $plugin = self::findPluginInstance($field, $plugin, $event->sender->tableName());
            foreach ($plugin->events() as $on => $handler) {
                $event->sender->on($on, is_string($handler) ? [$plugin, $handler] : $handler);
            }
        }
    }
412138
public function sendEvent(Event $event)
    {
        try {
            $this->eventFactory->addDefaultTagsToEntity($event);
            $this->sendEventThroughSenders($event);
        } catch (\Exception $exception) {
            $this->logException($exception);
        }
    }
713573
final protected function raise(DomainEvent $event) : void
    {
        $this->setStateHash($this->calculateNextStateHash($event));
        if ($event instanceof AbstractDomainEvent) {
            AbstractDomainEvent::initEvent($event, $this->getId(), $this->stateHash());
        }
        EventPublisher::instance()->post($event);
    }
1062047
protected function when(DomainEvent $event)
    {
        $method = 'when' . ClassToString::short($event);
        if (is_callable([$this, $method])) {
            $this->{$method}($event);
        }
    }