@param FindEvent $event

@throws DocumentManagerException
@throws DocumentNotFoundException
349726
public function handleFind(FindEvent $event)
    {
        $options = $event->getOptions();
        $aliasOrClass = $options['type'];
        $node = $this->nodeManager->find($event->getId());

        $hydrateEvent = new HydrateEvent($node, $event->getLocale(), $options);
        $this->eventDispatcher->dispatch(Events::HYDRATE, $hydrateEvent);
        $document = $hydrateEvent->getDocument();

        if ($aliasOrClass) {
            $this->checkAliasOrClass($aliasOrClass, $document);
        }

        $event->setDocument($hydrateEvent->getDocument());
    }
877239
public function onPostSerialize(ObjectEvent $event)
    {
        $visitor = $event->getVisitor();
        $document = $event->getObject();

        if (!$document instanceof PathBehavior || !$this->documentRegistry->hasDocument($document)) {
            return;
        }

        $visitor->addData('path', $this->documentInspector->getContentPath($document));
    }
323259
public function afterInitialize(Event $event, ModelsManager $manager, $model)
    {
        //Reflector
        /** @var \Phalcon\Annotations\Reflection $reflector */
        $reflector = $this->annotations->get($model);
        /**
         * Read the annotations in the class' docblock
         */
        $annotations = $reflector->getClassAnnotations();
        if ($annotations) {
            /**
             * Traverse the annotations
             */
            foreach ($annotations as $annotation) {
                switch ($annotation->getName()) {
                    /**
                     * Initializes the model's source
                     */
                    case 'Source':
                        $arguments = $annotation->getArguments();
                        $model->setConnectionService($arguments[0]);
                        $manager->setModelSource($model, $arguments[1]);
                        break;
                    /**
                     * Initializes Has-Many relations
                     */
                    case 'HasMany':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addHasMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                    /**
                     * Initializes Has-Many-To-Many relations
                     */
                    case 'HasManyToMany':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[6])) {
                            $arguments[6] = null;
                        }
                        $manager->addHasManyToMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6]);
                        break;
                    /**
                     * Initializes Has-One relations
                     */
                    case 'HasOne':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addHasOne($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                    /**
                     * Initializes Has-Many relations
                     */
                    case 'BelongsTo':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addBelongsTo($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                }
            }
        }
    }
465504
public function onPostSerialize(ObjectEvent $event)
    {
        /** @var Content $content */
        $content = $event->getObject();
        /** @var JsonSerializationVisitor $visitor */
        $visitor = $event->getVisitor();

        if (!($content instanceof Content)) {
            return;
        }

        foreach ($content->getData() as $key => $value) {
            $visitor->setData($key, $value);
        }

        $visitor->setData('publishedState', (WorkflowStage::PUBLISHED === $content->getWorkflowStage()));

        if (RedirectType::EXTERNAL === $content->getNodeType()) {
            $visitor->setData('linked', 'external');
        } elseif (RedirectType::INTERNAL === $content->getNodeType()) {
            $visitor->setData('linked', 'internal');
        }

        if (null !== $content->getLocalizationType()) {
            $visitor->setData('type', $content->getLocalizationType()->toArray());
        }

        $visitor->setData(
            '_permissions',
            $this->accessControlManager->getUserPermissionByArray(
                $content->getLocale(),
                PageAdmin::SECURITY_CONTEXT_PREFIX . $content->getWebspaceKey(),
                $content->getPermissions(),
                $this->tokenStorage->getToken()->getUser()
            )
        );
    }
1335982
public function onPostDeserialize(ObjectEvent $event)
    {
        /** @var TargetGroupInterface $targetGroup */
        $targetGroup = $event->getObject();

        if (!$targetGroup instanceof TargetGroupInterface) {
            return;
        }

        /* @var TargetGroupWebspaceInterface $webspace */
        if ($targetGroup->getWebspaces()) {
            foreach ($targetGroup->getWebspaces() as $webspace) {
                $webspace->setTargetGroup($targetGroup);
            }
        }

        if ($targetGroup->getRules()) {
            foreach ($targetGroup->getRules() as $rule) {
                $rule->setTargetGroup($targetGroup);
            }
        }
    }
698749
public function handlePostRemove(RemoveEvent $event)
    {
        $document = $event->getDocument();

        if (!$this->supports($document)) {
            return;
        }

        $oid = spl_object_hash($document);
        $event = $this->deleteEvents[$oid];

        $this->eventDispatcher->dispatch(
            ContentEvents::NODE_POST_DELETE,
            $event
        );

        unset($this->deleteEvents[$oid]);
    }
1085591
public function handleRemove(RemoveEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof RoutableBehavior) {
            return;
        }

        $locales = $this->documentInspector->getLocales($document);
        foreach ($locales as $locale) {
            $localizedDocument = $this->documentManager->find($document->getUuid(), $locale);

            $route = $this->routeRepository->findByEntity(
                $localizedDocument->getClass(),
                $localizedDocument->getUuid(),
                $locale
            );
            if (!$route) {
                continue;
            }

            $this->entityManager->remove($route);

            if ($document instanceof ChildrenBehavior) {
                $this->removeChildRoutes($document, $locale);
            }
        }

        $this->entityManager->flush();
    }
447678
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();

        if (!$document instanceof LocaleBehavior || !$this->documentRegistry->hasDocument($document)) {
            return;
        }

        $visitor = $event->getVisitor();

        $visitor->addData('availableLocales', $this->documentInspector->getLocales($document));
        $visitor->addData('contentLocales', $this->documentInspector->getConcreteLocales($document));

        $localizationState = $this->documentInspector->getLocalizationState($document);

        if (LocalizationState::GHOST === $localizationState) {
            $visitor->addData('type', ['name' => 'ghost', 'value' => $document->getLocale()]);
        }

        if (LocalizationState::SHADOW === $localizationState) {
            $visitor->addData('type', ['name' => 'shadow', 'value' => $document->getLocale()]);
        }
    }
12580
public function onPostConvertToDocument(PostConvertToDocumentEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof ArticleViewDocumentInterface) {
            return;
        }

        $document->setTargetWebspace($this->getTargetWebspace($document));
    }
969598
public function postCreate(CreateEvent $event)
    {
        $organization = $event->getObject();
        $key = $this->cryptoManager->generatePair();
        $key->setOrganization($organization);
        $this->om->persist($key);
        $this->om->flush();
    }
1247821
public function handleGetContentElement(GetContentElementEvent $event)
    {
        /** @var Controller $controllerAdapter */
        $controllerAdapter = $this->framework->getAdapter(Controller::class);

        $contentElement = $controllerAdapter->getContentElement(
            $event->getContentElementId(),
            $event->getColumn()
        );

        $event->setContentElementHtml($contentElement);
    }
712286
public function handlePersist(PersistEvent $event)
    {
        $options = $event->getOptions();
        $this->validateOptions($options);
        $document = $event->getDocument();
        $parentPath = null;
        $nodeName = null;

        if ($options['path']) {
            $parentPath = PathHelper::getParentPath($options['path']);
            $nodeName = PathHelper::getNodeName($options['path']);
        }

        if ($options['parent_path']) {
            $parentPath = $options['parent_path'];
        }

        if ($parentPath) {
            $event->setParentNode(
                $this->resolveParent($parentPath, $options)
            );
        }

        if ($options['node_name']) {
            if (!$event->hasParentNode()) {
                throw new DocumentManagerException(sprintf(
                    'The "node_name" option can only be used either with the "parent_path" option ' .
                    'or when a parent node has been established by a previous subscriber. ' .
                    'When persisting document: %s',
                    DocumentHelper::getDebugTitle($document)
                ));
            }

            $nodeName = $options['node_name'];
        }

        if (!$nodeName) {
            return;
        }

        if ($event->hasNode()) {
            $this->renameNode($event->getNode(), $nodeName);

            return;
        }

        if (!$event->getParentNode()->hasNode($nodeName)) {
            $node = $event->getParentNode()->addNode($nodeName);
        } elseif ($options['override']) {
            $node = $event->getParentNode()->getNode($nodeName);
        } else {
            throw new ItemExistsException(
                sprintf(
                    'The node \'%s\' already has a child named \'%s\'.',
                    $event->getParentNode()->getPath(),
                    $nodeName
                )
            );
        }

        $event->setNode($node);
    }
1148441
public function afterFind($event)
    {
        foreach ($this->attributes as $attribute) {
            $this->owner->{$attribute} = $this->htmlEncode($this->owner->{$attribute});
        }
    }
694086
public function createForm(FormEvent $event): void
    {
        $admin = $event->getAdmin();
        $action = $admin->getAction();
        $configuration = $action->getConfiguration();

        if (!$configuration->get('use_form')) {
            return;
        }
        $entity = null;

        if (LAGAdminBundle::LOAD_STRATEGY_UNIQUE === $configuration->get('load_strategy')) {
            if (!$admin->getEntities()->isEmpty()) {
                $entity = $admin->getEntities()->first();
            }
        }

        if ('create' === $action->getName() || 'edit' === $action->getName()) {
            $form = $this->adminFormFactory->createEntityForm($admin, $event->getRequest(), $entity);
            $event->addForm($form, 'entity');
        }

        if ('delete' === $action->getName()) {
            $form = $this->adminFormFactory->createDeleteForm($action, $event->getRequest(), $entity);
            $event->addForm($form, 'delete');
        }
    }
196474
public function deindexRemovedDocument(RemoveEvent $event)
    {
        $document = $event->getDocument();

        if (!$document instanceof StructureBehavior) {
            return;
        }

        if (!$document instanceof WorkflowStageBehavior) {
            $this->searchManager->deindex($document);
        } else {
            $workflowStage = $document->getWorkflowStage();

            foreach (WorkflowStage::$stages as $stage) {
                $document->setWorkflowStage($stage);
                $this->searchManager->deindex($document);
            }

            $document->setWorkflowStage($workflowStage);
        }
    }
989639
public function onPreSerialize(PreSerializeEvent $event)
    {
        $object = $event->getObject();
        if ($object instanceof ExtRefHoldingDocumentInterface && $object->isEmptyExtRefObject() === true) {
            $event->setType('Empty', [$object]);
        }
    }
880493
public function handlePersist(PersistEvent $event)
    {
        if (!$this->supports($event->getDocument())) {
            return;
        }

        $this->persistEvents[] = $event;
    }