loadLocation() public method

Not to be used for link generation.
public loadLocation ( integer $locationId ) : Location
$locationId integer
return eZ\Publish\Core\Repository\Values\Content\Location
 public function testLoadLocation()
 {
     $locationId = 123;
     $location = new Location(array('id' => $locationId));
     $this->locationService->expects($this->once())->method('loadLocation')->with($locationId)->will($this->returnValue($location));
     $this->urlAliasGenerator->loadLocation($locationId);
 }
 /**
  * Tries to match a request with a set of routes.
  *
  * If the matcher can not find information, it must throw one of the exceptions documented
  * below.
  *
  * @param Request $request The request to match
  *
  * @return array An array of parameters
  *
  * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException If no matching resource could be found
  */
 public function matchRequest(Request $request)
 {
     try {
         $urlAlias = $this->getUrlAlias($request->attributes->get('semanticPathinfo', $request->getPathInfo()));
         $params = array('_route' => self::URL_ALIAS_ROUTE_NAME);
         switch ($urlAlias->type) {
             case URLAlias::LOCATION:
                 $params += array('_controller' => static::LOCATION_VIEW_CONTROLLER, 'locationId' => $urlAlias->destination, 'viewType' => ViewManager::VIEW_TYPE_FULL, 'layout' => true);
                 $request->attributes->set('locationId', $urlAlias->destination);
                 // For Location alias setup 301 redirect to Location's current URL when:
                 // 1. alias is history
                 // 2. alias is custom with forward flag true
                 if ($urlAlias->isHistory === true || $urlAlias->isCustom === true && $urlAlias->forward === true) {
                     $request->attributes->set('semanticPathinfo', $this->generate($this->generator->loadLocation($urlAlias->destination)));
                     $request->attributes->set('needsRedirect', true);
                     // Specify not to prepend siteaccess while redirecting when applicable since it would be already present (see UrlAliasGenerator::doGenerate())
                     $request->attributes->set('prependSiteaccessOnRedirect', false);
                 }
                 if (isset($this->logger)) {
                     $this->logger->info("UrlAlias matched location #{$urlAlias->destination}. Forwarding to ViewController");
                 }
                 break;
             case URLAlias::RESOURCE:
             case URLAlias::VIRTUAL:
                 $request->attributes->set('semanticPathinfo', '/' . trim($urlAlias->destination, '/'));
                 // In URLAlias terms, "forward" means "redirect".
                 if ($urlAlias->forward) {
                     $request->attributes->set('needsRedirect', true);
                 } else {
                     $request->attributes->set('needsForward', true);
                 }
                 break;
         }
         return $params;
     } catch (NotFoundException $e) {
         throw new ResourceNotFoundException($e->getMessage(), $e->getCode(), $e);
     }
 }
 /**
  * Tries to match a request with a set of routes.
  *
  * If the matcher can not find information, it must throw one of the exceptions documented
  * below.
  *
  * @param Request $request The request to match
  *
  * @return array An array of parameters
  *
  * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException If no matching resource could be found
  */
 public function matchRequest(Request $request)
 {
     try {
         $requestedPath = $request->attributes->get('semanticPathinfo', $request->getPathInfo());
         $urlAlias = $this->getUrlAlias($requestedPath);
         if ($this->rootLocationId === null) {
             $pathPrefix = '/';
         } else {
             $pathPrefix = $this->generator->getPathPrefixByRootLocationId($this->rootLocationId);
         }
         $params = array('_route' => self::URL_ALIAS_ROUTE_NAME);
         switch ($urlAlias->type) {
             case URLAlias::LOCATION:
                 $location = $this->generator->loadLocation($urlAlias->destination);
                 $params += array('_controller' => static::VIEW_ACTION, 'contentId' => $location->contentId, 'locationId' => $urlAlias->destination, 'viewType' => ViewManager::VIEW_TYPE_FULL, 'layout' => true);
                 $request->attributes->set('locationId', $urlAlias->destination);
                 // For Location alias setup 301 redirect to Location's current URL when:
                 // 1. alias is history
                 // 2. alias is custom with forward flag true
                 // 3. requested URL is not case-sensitive equal with the one loaded
                 if ($urlAlias->isHistory === true || $urlAlias->isCustom === true && $urlAlias->forward === true) {
                     $request->attributes->set('semanticPathinfo', $this->generate($location));
                     $request->attributes->set('needsRedirect', true);
                     // Specify not to prepend siteaccess while redirecting when applicable since it would be already present (see UrlAliasGenerator::doGenerate())
                     $request->attributes->set('prependSiteaccessOnRedirect', false);
                 } elseif ($this->needsCaseRedirect($urlAlias, $requestedPath, $pathPrefix)) {
                     $request->attributes->set('semanticPathinfo', $this->removePathPrefix($urlAlias->path, $pathPrefix));
                     $request->attributes->set('needsRedirect', true);
                 }
                 if (isset($this->logger)) {
                     $this->logger->info("UrlAlias matched location #{$urlAlias->destination}. Forwarding to ViewController");
                 }
                 break;
             case URLAlias::RESOURCE:
                 // In URLAlias terms, "forward" means "redirect".
                 if ($urlAlias->forward) {
                     $request->attributes->set('semanticPathinfo', '/' . trim($urlAlias->destination, '/'));
                     $request->attributes->set('needsRedirect', true);
                 } elseif ($this->needsCaseRedirect($urlAlias, $requestedPath, $pathPrefix)) {
                     // Handle case-correction redirect
                     $request->attributes->set('semanticPathinfo', $this->removePathPrefix($urlAlias->path, $pathPrefix));
                     $request->attributes->set('needsRedirect', true);
                 } else {
                     $request->attributes->set('semanticPathinfo', '/' . trim($urlAlias->destination, '/'));
                     $request->attributes->set('needsForward', true);
                 }
                 break;
             case URLAlias::VIRTUAL:
                 // Handle case-correction redirect
                 if ($this->needsCaseRedirect($urlAlias, $requestedPath, $pathPrefix)) {
                     $request->attributes->set('semanticPathinfo', $this->removePathPrefix($urlAlias->path, $pathPrefix));
                     $request->attributes->set('needsRedirect', true);
                 } else {
                     // Virtual aliases should load the Content at homepage URL
                     $request->attributes->set('semanticPathinfo', '/');
                     $request->attributes->set('needsForward', true);
                 }
                 break;
         }
         return $params;
     } catch (NotFoundException $e) {
         throw new ResourceNotFoundException($e->getMessage(), $e->getCode(), $e);
     }
 }