Sulu\Component\Webspace\Manager\WebspaceManagerInterface::findPortalInformationByUrl PHP Method

findPortalInformationByUrl() public method

Returns the portal with the given url (which has not necessarily to be the main url).
public findPortalInformationByUrl ( string $url, string $environment ) : PortalInformation | null
$url string The url to search for
$environment string The environment in which the url should be searched
return Sulu\Component\Webspace\PortalInformation | null
    public function findPortalInformationByUrl($url, $environment);

Usage Example

Esempio n. 1
0
 /**
  * Analyzes the current request, and saves the values for portal, localization and segment for further usage.
  *
  * @param Request $request The request to analyze
  *
  * @throws Exception\UrlMatchNotFoundException
  */
 public function analyze(Request $request)
 {
     $url = $request->getHost() . $request->getPathInfo();
     $portalInformation = $this->webspaceManager->findPortalInformationByUrl($url, $this->environment);
     $this->getParameter = $request->query->all();
     $this->postParameter = $request->request->all();
     if ($portalInformation === null) {
         throw new UrlMatchNotFoundException($request->getUri());
     }
     $this->setCurrentMatchType($portalInformation->getType());
     $this->setCurrentRedirect($portalInformation->getRedirect());
     $this->analyticsKey = $portalInformation->getAnalyticsKey();
     if ($portalInformation->getType() == RequestAnalyzerInterface::MATCH_TYPE_REDIRECT) {
         $this->setCurrentPortalUrl($portalInformation->getUrl());
         $this->setCurrentWebspace($portalInformation->getWebspace());
         return;
     }
     $this->setCurrentPortalUrl($portalInformation->getUrl());
     $this->setCurrentLocalization($portalInformation->getLocalization());
     $this->setCurrentPortal($portalInformation->getPortal());
     $this->setCurrentWebspace($portalInformation->getWebspace());
     $this->setCurrentSegment($portalInformation->getSegment());
     $request->setLocale($portalInformation->getLocalization()->getLocalization());
     list($resourceLocator, $format) = $this->getResourceLocatorFromRequest($portalInformation, $request);
     // get the path and set it on the request
     $this->setCurrentResourceLocator($resourceLocator);
     if ($format) {
         $request->setRequestFormat($format);
     }
     // get the resource locator prefix and set it
     $this->setCurrentResourceLocatorPrefix(substr($portalInformation->getUrl(), strlen($request->getHost())));
 }