Occurs on classcontent.onflush events.

@param Event $event
194073
public static function onFlushContent(Event $event)
    {
        $content = $event->getTarget();
        $application = $event->getApplication();

        $token = $application->getSecurityContext()->getToken();
        if (!($token instanceof BBUserToken)) {
            return;
        }

        $em = $application->getEntityManager();
        $uow = $em->getUnitOfWork();

        if ($uow->isScheduledForInsert($content) && AbstractClassContent::STATE_NEW === $content->getState()) {
            if (null === $draft = $content->getDraft()) {
                $draft = $em->getRepository('BackBee\ClassContent\Revision')->checkout($content, $token);
            }

            $content->setDraft($draft);
            $em->persist($draft);
            $uow->computeChangeSet($em->getClassMetadata('BackBee\ClassContent\Revision'), $draft);
        } elseif ($uow->isScheduledForDelete($content)) {
            $revisions = $em->getRepository('BackBee\ClassContent\Revision')->getRevisions($content);
            foreach ($revisions as $revision) {
                $revision->setContent(null);
                $revision->setState(Revision::STATE_DELETED);
                $uow->computeChangeSet($em->getClassMetadata('BackBee\ClassContent\Revision'), $revision);
            }
        }
    }
1159073
public static function onInclude(Event $event)
    {
        $dispatcher = $event->getDispatcher();
        if (null !== $dispatcher->getApplication()) {
            if (null === $em = $dispatcher->getApplication()->getEntityManager()) {
                return;
            }

            $shortClassname = AbstractClassContent::getShortClassname($event->getTarget());
            $fullClassname = AbstractClassContent::getFullClassname($event->getTarget());
            foreach (class_parents($fullClassname) as $classname) {
                $em->getClassMetadata($classname)->addDiscriminatorMapClass($shortClassname, $fullClassname);

                if ('BackBee\ClassContent\AbstractClassContent' === $classname) {
                    break;
                }
            }
        }
    }
793454
public static function clear(string $event = '') {
		if (empty($event)) {
			self::$events = [];
		} else {
			self::$events[$event] = [];
		}
	}
922430
public function beforeRender(Event $event)
    {
        parent::beforeRender($event);

        $this->set('detect', $this->detect);
    }
227847
protected function doSendEvent(Event $event): void
    {
        $envelope = new TransportEnvelope($event, 'json');
        $this->client->putRecord([
            'StreamName'   => $this->router->forEvent($event),
            'PartitionKey' => $this->router->partitionForEvent($event),
            'Data'         => $envelope->toString(),
        ]);
    }
811788
public function recordThat(Event $event): void
    {
        $this->eventCollection()->record(EventMessage::create($event));
    }
430788
public function beforeRender(Event $event)
    {
        parent::beforeRender($event);

        $this->set('title', $this->Settings['alias']);
    }
26103
public function queueEvent($event)
    {
        $this->queue->enqueue($event);

        $class = get_class($event);
        foreach ($this->synchronousEventMap->getListenersForEvent($class) as $listener)
        {
            $this->invokeListener($listener, $event);
        }
    }
451743
public function handleFlushLive(FlushEvent $event)
    {
        if (count($this->liveDocuments) < 1) {
            return;
        }

        foreach ($this->liveDocuments as $documentData) {
            $document = $this->documentManager->find($documentData['uuid'], $documentData['locale']);
            $this->documentManager->refresh($document);

            $this->liveIndexer->index($document);
        }
        $this->liveIndexer->flush();
        $this->liveDocuments = [];
    }
1010084
public function onPostAutoloadDump(Event $event)
    {
        $this->io->overwriteError('<info>Assembling config files</info>');

        $this->builder = new Builder();

        $this->initAutoload();
        $this->scanPackages();
        $this->reorderFiles();
        $this->showDepsTree();

        $this->builder->buildAllConfigs($this->files);
    }
560338
private function apply($event, $prefix = 'apply'): void
    {
        Guard::event($event);

        $handler = $prefix . \get_class_name($event);

        if (false === \method_exists($this, $handler)) {
            return;
        }

        $this->{$handler}($event);

        $this->events[] = $event;
    }
26013
public function onFlushPage(Event $event)
    {
        // Checks if page caching is available
        $this->object = $event->getTarget();
        if (false === ($this->object instanceof Page) || false === $this->checkCachePageEvent(false)) {
            return;
        }

        if (true === $this->page_cache_deletion_done) {
            return;
        }

        $pages = ScheduledEntities::getScheduledEntityUpdatesByClassname(
            $this->application->getEntityManager(), 'BackBee\NestedNode\Page'
        );
        if (0 === count($pages)) {
            return;
        }

        $page_uids = array();
        foreach ($pages as $page) {
            $page_uids[] = $page->getUid();
        }

        $this->cache_page->removeByTag($page_uids);
        $this->page_cache_deletion_done = true;
        $this->application->debug(sprintf(
            'Remove cache for `%s(%s)`.',
            get_class($this->object),
            implode(', ', $page_uids)
        ));
    }
512181
public function forget($event)
    {
        if (mb_strpos($event, '*') !== false) {
            unset($this->wildcards[$event]);
        } else {
            unset($this->listeners[$event], $this->sorted[$event]);
        }
    }
69410
public function onRequestSent(Event $event)
    {
        $request = $event['request'];
        $response = $event['response'];

        if ($request->getParams()->get('cache.hit') === null &&
            $this->canCache->canCacheRequest($request) &&
            $this->canCache->canCacheResponse($response)
        ) {
            $this->storage->cache($request, $response);
        }

        $this->addResponseHeaders($request, $response);
    }
1283784
protected function eventWasProcessed($event)
    {
        if ($this->eventExpired($event)) {
            return true;
        }

        $this->resetEventCache($event);

        return false;
    }
810820
public function fireEvent(string $event): void
    {
        $this->log->debug('Event {event} has been fired.', ['event' => $event]);
        foreach ($this->event_handlers as $handler) {
            /** @var EventHandler $handler */
            if ($event === $handler->getEvent()) {
                $handler->execute();
            }
        }
    }
856488
public function onFlush(OnFlushEventArgs $eventArgs): void
    {
        $uow = $eventArgs->getEntityManager()->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            $this->storeEntityToPublish($entity, 'createdEntities');
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            $this->storeEntityToPublish($entity, 'updatedEntities');
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            $this->storeEntityToPublish($entity, 'deletedEntities');
        }
    }