Page public url event handler.

@param ResourceEventInterface $event
189932
public function onPagePublicUrl(ResourceEventInterface $event)
    {
        $resource = $event->getResource();

        if (!$resource instanceof PageInterface) {
            return;
        }

        $event->stopPropagation();

        if (!$resource->isEnabled() || $resource->isDynamicPath()) {
            return;
        }

        $event->addData('route', $resource->getRoute());
    }
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);

    }
954338
private function getMenuFromEvent(ResourceEventInterface $event)
    {
        $resource = $event->getResource();

        if (!$resource instanceof MenuInterface) {
            throw new InvalidArgumentException("Expected instance of MenuInterface");
        }

        return $resource;
    }
983732
public function handleHandleHttpRequestEvent(HandleHttpRequestEvent $event) {
        $event->setResponse(
            $this->requestHandler->handle($event->getRequest())
        );
    }
1031387
protected function dispatchEvent(ResourceEvent $event)
    {
        $this->ed->dispatch(\get_class($event), $event);

        return $event;
    }
707011
public function handlePublish(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof PageDocument || !$this->hasChangedResourceSegment($document)) {
            return;
        }

        $this->routeUpdater->update($document);
    }
913931
public function urlSecret(Event $event)
    {
        $query = $event['request']->getQuery();

        $query->set('client_id', $this->auth['client_id']);
        $query->set('client_secret', $this->auth['client_secret']);
    }
877564
public function handleRemove(RemoveEvent $event)
    {
        $document = $event->getDocument();
        if (!($document instanceof CustomUrlBehavior)) {
            return;
        }

        foreach ($this->inspector->getReferrers($document) as $referrer) {
            if ($referrer instanceof RouteBehavior) {
                $this->documentManager->remove($referrer);
            }
        }
    }
574773
public function redirectTrailingSlashOrHtml(GetResponseForExceptionEvent $event)
    {
        if (!$event->getException() instanceof NotFoundHttpException) {
            return;
        }

        $request = $event->getRequest();

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

        $prefix = $attributes->getAttribute('resourceLocatorPrefix');
        $resourceLocator = $attributes->getAttribute('resourceLocator');

        $route = '/' . trim($prefix . $resourceLocator, '/');
        if (!in_array($request->getRequestFormat(), ['htm', 'html'])
            || $route === $request->getPathInfo()
            || !$this->matchRoute($request->getSchemeAndHttpHost() . $route)
        ) {
            return;
        }

        $event->setResponse(new RedirectResponse($route, 301));
    }
709004
public function onProductIndex(ResourceControllerEvent $event): void
    {
        $currentRequest = $this->requestStack->getCurrentRequest();
        if (!$currentRequest instanceof Request) {
            return;
        }

        // Only sane way to extract the reference to the taxon
        if (!$currentRequest->attributes->has('slug')) {
            return;
        }

        $taxon = $this->taxonRepository->findOneBySlug(
            $currentRequest->attributes->get('slug'),
            $this->localeContext->getLocaleCode()
        );

        if (!$taxon instanceof TaxonInterface) {
            return;
        }

        $currentRequest->attributes->set('nglayouts_sylius_taxon', $taxon);
        // We set context here instead in a ContextProvider, since sylius.taxon.show
        // event happens too late, after onKernelRequest event has already been executed
        $this->context->set('sylius_taxon_id', (int) $taxon->getId());
    }
635794
public function preDelete(ResourceEvent $event)
    {
        /** @var CategoryInterface $resource */
        $resource = $event->getSubject();

        if ($resource->getQuestions()->count() > 0) {
            $event->stop('question_exist', 'danger');
        }
    }
984074
public function onCreate(CreateResourceEvent $event)
    {
        $form = $this->formFactory->create(new ActivityType(), new Activity());
        $form->handleRequest($this->request);

        if ($form->isValid()) {
            $published = $form->get('published')->getData();
            $event->setPublished($published);
            $activity = $form->getData();
            $activity->setName($activity->getTitle());
            $activityParameters = new ActivityParameters();
            $activityParameters->setActivity($activity);
            $activity->setParameters($activityParameters);
            $event->setResources(array($activity));
            $event->stopPropagation();

            return;
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:Resource:createForm.html.twig',
            array(
                'form' => $form->createView(),
                'resourceType' => 'activity'
            )
        );

        $event->setErrorFormContent($content);
        $event->stopPropagation();
    }
382346
public function updateConfiguration(ResourceEvent $event)
    {
        $resource = $event->getSubject();

        if ($resource instanceof UserSessionInterface) {
            $configuration = clone $resource->getConfiguration();
            $resource->setConfiguration($configuration);
        }
    }
89383
public function onRename(LogGenericEvent $event)
    {
        if (
            $event instanceof LogResourceUpdateEvent
            && 'Icap\WebsiteBundle\Entity\Website' === $event->getResource()->getClass()
            && 'resource-update_rename' === $event->getAction()
            && $event->getDetails()['resource']['changeSet']['name'][0] !== $event->getDetails()['resource']['changeSet']['name'][1]
        ) {
            $resourceNode = $event->getResource();
            $newTitle = $event->getDetails()['resource']['changeSet']['name'][1];

            $this->websiteManager->renameRootPageByResourceNode($newTitle, $resourceNode);
        }
    }
566191
public function onPostSerialize(ObjectEvent $event)
    {
        if ($this->container->has('routing')) {
            $uri = $this->container->get('routing')->getUri($event->getObject()->getUrl());
            $event->getVisitor()->addData('uri', $uri);
        }
    }
83676
public function onDelete(DeleteResourceEvent $event)
    {
        $ds = DIRECTORY_SEPARATOR;

        /** @var File $resource */
        $resource = $event->getResource();
        $workspace = $resource->getResourceNode()->getWorkspace();
        $hashName = $resource->getHashName();

        $archiveFile = $this->filesDir.$ds.'webresource'.$ds.$workspace->getUuid().$ds.$hashName;
        $webResourcesPath = $this->uploadDir.$ds.'webresource'.$ds.$workspace->getUuid().$ds.$hashName;

        if (file_exists($archiveFile)) {
            $event->setFiles([$archiveFile]);
        }
        if (file_exists($webResourcesPath)) {
            try {
                $this->deleteFiles($webResourcesPath);
            } catch (\Exception $e) {
            }
        }
        $this->om->remove($resource);
        $event->stopPropagation();
    }
881648
private function removeResource(ResourceEventInterface $event)
    {
        $resource = $event->getResource();
        $this->remove($resource);

        try {
            $this->flush();
        } catch(DBALException $e) {
            /*if ($this->get('kernel')->getEnvironment() === 'dev') {
                throw $e;
            }*/
            if (null !== $previous = $e->getPrevious()) {
                if ($previous instanceof \PDOException && $previous->getCode() == 23000) {
                    return $event->addMessage(new ResourceMessage(
                        'Cette ressource est liée à d\'autres ressources et ne peut pas être supprimée.',
                        ResourceMessage::TYPE_ERROR
                    ));
                }
            }
            return $event->addMessage(new ResourceMessage(
                'L\'application a rencontré une erreur relative à la base de données. La ressource n\'a pas été supprimée.',
                ResourceMessage::TYPE_ERROR
            ));
        }

        return $event->addMessage(new ResourceMessage(
            'La ressource a été supprimée avec succès.',
            ResourceMessage::TYPE_SUCCESS
        ));
    }