eZ\Publish\Core\MVC\Symfony\Routing\Generator\UrlAliasGenerator::getPathPrefixByRootLocationId PHP Method

getPathPrefixByRootLocationId() public method

Returns path corresponding to $rootLocationId.
public getPathPrefixByRootLocationId ( integer $rootLocationId, array $languages = null, string $siteaccess = null ) : string
$rootLocationId integer
$languages array
$siteaccess string
return string
    public function getPathPrefixByRootLocationId($rootLocationId, $languages = null, $siteaccess = null)
    {
        if (!$rootLocationId) {
            return '';
        }
        if (!isset($this->pathPrefixMap[$siteaccess])) {
            $this->pathPrefixMap[$siteaccess] = array();
        }
        if (!isset($this->pathPrefixMap[$siteaccess][$rootLocationId])) {
            $this->pathPrefixMap[$siteaccess][$rootLocationId] = $this->repository->getURLAliasService()->reverseLookup($this->loadLocation($rootLocationId), null, false, $languages)->path;
        }
        return $this->pathPrefixMap[$siteaccess][$rootLocationId];
    }

Usage Example

 public function testGetPathPrefixByRootLocationId()
 {
     $rootLocationId = 123;
     $rootLocation = new Location(array('id' => $rootLocationId));
     $pathPrefix = '/foo/bar';
     $rootUrlAlias = new URLAlias(array('path' => $pathPrefix));
     $this->locationService->expects($this->once())->method('loadLocation')->with($rootLocationId)->will($this->returnValue($rootLocation));
     $this->urlAliasService->expects($this->once())->method('reverseLookup')->with($rootLocation)->will($this->returnValue($rootUrlAlias));
     $this->assertSame($pathPrefix, $this->urlAliasGenerator->getPathPrefixByRootLocationId($rootLocationId));
 }
All Usage Examples Of eZ\Publish\Core\MVC\Symfony\Routing\Generator\UrlAliasGenerator::getPathPrefixByRootLocationId