Loops thru current webspace locales and generates routes for them.

@param ObjectEvent $event
185538
public function addUrlsOnPostSerialize(ObjectEvent $event)
    {
        $article = $event->getObject();
        $visitor = $event->getVisitor();
        $context = $event->getContext();
        $request = $this->requestStack->getCurrentRequest();

        if (!$article instanceof ArticleDocument || !$context->attributes->containsKey('website') || !$request) {
            return;
        }

        /** @var RequestAttributes $attributes */
        $attributes = $request->get('_sulu');
        if (!$attributes) {
            return;
        }

        /** @var Webspace $webspace */
        $webspace = $attributes->getAttribute('webspace');
        if (!$webspace) {
            return;
        }

        $urls = [];
        foreach ($webspace->getAllLocalizations() as $localization) {
            $locale = $localization->getLocale();
            $route = $this->routeRepository->findByEntity(get_class($article), $article->getUuid(), $locale);

            $urls[$locale] = '/';
            if ($route) {
                $urls[$locale] = $route->getPath();
            }
        }

        $visitor->addData('urls', $context->accept($urls));
    }
271110
public function onPreSubmit(FormEvent $event)
    {
        $contentInfo = null;
        $contentLanguages = [];
        $form = $event->getForm();
        $data = $event->getData();

        if (isset($data['location'])) {
            try {
                $location = $this->locationService->loadLocation($data['location']);
            } catch (NotFoundException $e) {
                $location = null;
            }

            if (null !== $location) {
                $contentInfo = $location->getContentInfo();
                $versionInfo = $this->contentService->loadVersionInfo($contentInfo);
                $contentLanguages = $versionInfo->languageCodes;
            }
        }

        $this->addLanguageFields($form, $contentLanguages, $contentInfo);
    }
237794
public function handleSetNodeOnPersist(PersistEvent $event)
    {
        $document = $event->getDocument();
        $options = $event->getOptions();
        if (!$document instanceof RouteBehavior || !array_key_exists('path', $options)) {
            return;
        }

        $parentPath = PathHelper::getParentPath($options['path']);
        $parentNode = $this->nodeManager->createPath($parentPath);

        $nodeName = PathHelper::getNodeName($options['path']);
        if (!$parentNode->hasNode($nodeName)) {
            return;
        }

        $node = $parentNode->getNode($nodeName);
        if ($node->hasProperty(self::NODE_HISTORY_FIELD)) {
            return;
        }

        $event->setNode($node);
        $event->setParentNode($parentNode);
    }
436630
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();
        $context = $event->getContext();

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

        $visitor = $event->getVisitor();
        $structureMetadata = $this->inspector->getStructureMetadata($document);

        if ($structureMetadata) {
            $visitor->addData('template', $document->getStructureType());
            $visitor->addData('originTemplate', $document->getStructureType());
            $visitor->addData('internal', false);
            $visitor->addData(
                'localizedTemplate',
                $structureMetadata->getTitle(
                    $this->inspector->getLocale($document)
                )
            );

            if (false !== array_search('defaultPage', $context->attributes->get('groups')->getOrElse([]))) {
                $this->addStructureProperties($structureMetadata, $document, $visitor);
            }

            // create bread crumbs
            if (false !== array_search('breadcrumbPage', $context->attributes->get('groups')->getOrElse([]))) {
                $this->addBreadcrumb($document, $visitor);
            }
        }
    }
1318203
public function onPostBind($event)
    {
        $form = $event->getForm();

        if ( ! $form->isRoot()) return;

        $clientData = $event->getForm()->getData();

        if ( ! is_object($clientData)) return;

        $this->filterService->filterEntity($clientData);

    }
895078
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();

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

        $visitor = $event->getVisitor();

        $visitor->addData('shadowLocales', $this->documentInspector->getShadowLocales($document));
    }
1085221
public function beforeFind(Event $event)
    {
        //Inject default query handlers
        $queryParameters = Hash::merge($this->getConfig('queryParameters'), [
            'sort' => [
                'callable' => [$this, '_sortParameter'],
            ],
            'include' => [
                'callable' => [$this, '_includeParameter']
            ],
            'fields' => [
                'callable' => [$this, '_fieldSetsParameter']
            ]
        ]);

        foreach ($queryParameters as $parameter => $options) {
            if (is_callable($options)) {
                $options = [
                    'callable' => $options
                ];
            }

            if (!is_callable($options['callable'])) {
                throw new \InvalidArgumentException('Invalid callable supplied for query parameter ' . $parameter);
            }

            $options['callable']($this->_request()->getQuery($parameter), $event->getSubject(), $options);
        }
    }
423814
public function handleScheduleIndex(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof ArticleDocument) {
            if (!$document instanceof ArticlePageDocument) {
                return;
            }

            $document = $document->getParent();
        }

        $this->documents[$document->getUuid()] = [
            'uuid' => $document->getUuid(),
            'locale' => $document->getLocale(),
        ];
    }
31907
public function handle($event)
    {
        if ($event instanceof RouteMatched) {
            $this->handleLaravelRoute($event);
        }

        if ($event instanceof GzeroRouteMatched) {
            $this->handleRoute($event);
        }
    }
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));
    }
398340
private function updateRoute($document, $generateRoutes)
    {
        $locales = $this->documentInspector->getLocales($document);
        $webspaceKey = $this->documentInspector->getWebspace($document);
        $uuid = $this->documentInspector->getUuid($document);
        $path = $this->documentInspector->getPath($document);
        $parentUuid = $this->documentInspector->getUuid($this->documentInspector->getParent($document));

        $defaultNode = $this->defaultSession->getNode($path);
        $liveNode = $this->liveSession->getNode($path);

        $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);

        foreach ($locales as $locale) {
            $localizedDocument = $this->documentManager->find($uuid, $locale);

            if (RedirectType::NONE !== $localizedDocument->getRedirectType()) {
                continue;
            }

            $resourceSegmentPropertyName = $this->encoder->localizedSystemName(
                $this->getResourceSegmentProperty($localizedDocument)->getName(),
                $locale
            );

            $this->updateResourceSegmentProperty(
                $defaultNode,
                $resourceSegmentPropertyName,
                $parentUuid,
                $webspaceKey,
                $locale
            );

            if ($liveNode->hasProperty($resourceSegmentPropertyName)) {
                $this->updateResourceSegmentProperty(
                    $liveNode,
                    $resourceSegmentPropertyName,
                    $parentUuid,
                    $webspaceKey,
                    $locale
                );

                // if the method is called with the generateRoutes flag it will create a new route
                // this happens on a move, but not on copy, because copy results in a draft page without url
                if ($generateRoutes) {
                    $localizedDocument->setResourceSegment($liveNode->getPropertyValue($resourceSegmentPropertyName));
                    $resourceLocatorStrategy->save($localizedDocument, null);
                    $localizedDocument->setResourceSegment($defaultNode->getPropertyValue($resourceSegmentPropertyName));
                }
            }
        }
    }
832950
public function addGlobal(Event $event)
    {
        $floatActionDropdown = $this->menuBuilder->getFloatActionDropdown();

        $floatActionDropdown->addChild('menu.page.new', [
            'route'          => 'victoire_core_page_new',
            'linkAttributes' => [
                'class' => 'v-drop__anchor',
            ],
        ])
            ->setExtra('translation_domain', 'victoire')
            ->setLinkAttribute('data-toggle', 'vic-modal');
    }
17069
public function setTitleOnNode(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();

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

        if ($document instanceof LocalizedTitleBehavior) {
            if (!$event->getLocale()) {
                return;
            }

            $event->getNode()->setProperty(
                $this->propertyEncoder->localizedContentName(static::PROPERTY_NAME, $event->getLocale()),
                $document->getTitle()
            );
        } else {
            $event->getNode()->setProperty(
                $this->propertyEncoder->contentName(static::PROPERTY_NAME),
                $document->getTitle()
            );
        }
    }
1032969
public function onPreSetData(FormEvent $event)
    {
        /** @var CustomUrlAddData $data */
        $data = $event->getData();
        $location = $data->getLocation();
        if (null === $location) {
            return;
        }
        $contentInfo = $location->getContentInfo();
        $versionInfo = $this->contentService->loadVersionInfo($contentInfo);
        $contentLanguages = $versionInfo->languageCodes;

        $form = $event->getForm();

        $form->add(
            'language',
            ChoiceType::class,
            [
                'multiple' => false,
                'choice_loader' => new CallbackChoiceLoader($this->getCallableFilter($contentLanguages)),
                'choice_value' => 'languageCode',
                'choice_label' => 'name',
            ]
        );
    }
809793
public function addTitleOnPostSerialize(ObjectEvent $event)
    {
        $articlePage = $event->getObject();
        $visitor = $event->getVisitor();
        $context = $event->getContext();

        if (!$articlePage instanceof ArticlePageDocument) {
            return;
        }

        $visitor->addData('title', $context->accept($articlePage->getParent()->getTitle()));
    }
264390
public function dispatchEvent(object $event): object
    {
        if (isset($this->i__dispatcher)) {
            $this->i__dispatcher->dispatch($event);
        }

        return $event;
    }
1211859
public function onPostSerialize(ObjectEvent $event)
    {
        $teaser = $event->getObject();
        $visitor = $event->getVisitor();
        $context = $event->getContext();

        if (!($teaser instanceof Teaser)) {
            return;
        }

        $visitor->addData('teaserId', $context->accept(sprintf('%s;%s', $teaser->getType(), $teaser->getId())));
    }