eZ\Publish\Core\MVC\Symfony\Templating\GlobalHelper::getSystemUriString PHP Method

getSystemUriString() public method

System URI is the URI for internal content controller. E.g. /content/location/123/full. If current route is not an URLAlias, then the current Pathinfo is returned.
public getSystemUriString ( ) : null | string
return null | string
    public function getSystemUriString()
    {
        $request = $this->getCurrentRequest();
        if ($request) {
            if ($request->attributes->get('_route') === UrlAliasRouter::URL_ALIAS_ROUTE_NAME) {
                return $this->router->generate('_ezpublishLocation', array('locationId' => $request->attributes->get('locationId'), 'viewType' => $request->attributes->get('viewType')));
            }
            return $this->getRequestedUriString();
        }
    }

Usage Example

 public function testGetSystemUriString()
 {
     $locationId = 123;
     $viewType = 'full';
     $expectedSystemUriString = '/content/location/123/full';
     $request = Request::create('/ezdemo_site/foo/bar');
     $request->attributes->set('_route', UrlAliasRouter::URL_ALIAS_ROUTE_NAME);
     $request->attributes->set('locationId', $locationId);
     $request->attributes->set('viewType', $viewType);
     $this->router->expects($this->once())->method('generate')->with('_ezpublishLocation', array('locationId' => $locationId, 'viewType' => $viewType))->will($this->returnValue($expectedSystemUriString));
     $this->helper->setRequest($request);
     $this->assertSame($expectedSystemUriString, $this->helper->getSystemUriString());
 }