예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function getUrls(Webspace $webspace, $environment)
 {
     $urls = [];
     foreach ($this->customUrlManager->findUrls($webspace->getKey()) as $customUrl) {
         $urls[] = new Url($customUrl, $environment);
     }
     return $urls;
 }
예제 #2
0
 /**
  * Invalidate custom-urls for persisted pages.
  *
  * @param PersistEvent $event
  */
 public function handlePersist(PersistEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof BasePageDocument) {
         return;
     }
     foreach ($this->manager->findByPage($document) as $customUrlDocument) {
         $this->manager->invalidate($customUrlDocument);
     }
 }
예제 #3
0
 /**
  * Matches given url to portal-information.
  *
  * @param string $url
  * @param PortalInformation $portalInformation
  * @param Request $request
  *
  * @return RequestAttributes|void
  */
 private function matchCustomUrl($url, PortalInformation $portalInformation, Request $request)
 {
     $webspace = $portalInformation->getWebspace();
     $routeDocument = $this->customUrlManager->findRouteByUrl($url, $webspace->getKey());
     if (!$routeDocument) {
         return [];
     } elseif ($routeDocument->isHistory()) {
         // redirect happen => no portal is needed
         return ['customUrlRoute' => $routeDocument];
     }
     $customUrlDocument = $this->customUrlManager->findByUrl($url, $webspace->getKey(), $routeDocument->getTargetDocument()->getTargetLocale());
     if ($customUrlDocument === null || $customUrlDocument->isPublished() === false || $customUrlDocument->getTargetDocument() === null || $customUrlDocument->getTargetDocument()->getWorkflowStage() !== WorkflowStage::PUBLISHED) {
         // error happen because this custom-url is not published => no portal is needed
         return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument];
     }
     $localization = $this->parse($customUrlDocument->getTargetLocale());
     $portalInformations = $this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale($portalInformation->getWebspace()->getKey(), $localization->getLocalization(), $this->environment);
     if (0 === count($portalInformations)) {
         return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument];
     }
     return ['portalInformation' => $portalInformation, 'localization' => $localization, 'customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument, 'urlExpression' => $this->generator->generate($customUrlDocument->getBaseDomain(), $customUrlDocument->getDomainParts())];
 }