eZ\Publish\Core\MVC\Symfony\Security\HttpUtils::generateUri PHP Метод

generateUri() публичный Метод

public generateUri ( $request, $path )
    public function generateUri($request, $path)
    {
        if ($this->isRouteName($path)) {
            // Remove siteaccess attribute to avoid triggering reverse siteaccess lookup during link generation.
            $request->attributes->remove('siteaccess');
        }
        return parent::generateUri($request, $this->analyzeLink($path));
    }

Usage Example

Пример #1
0
 /**
  * @dataProvider generateUriProvider
  */
 public function testGenerateUri($uri, $isUriRouteName, $siteAccessUri, $expected)
 {
     $siteAccess = new SiteAccess('test', 'test');
     if ($uri[0] === '/') {
         $matcher = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\URILexer');
         $matcher->expects($this->once())->method('analyseLink')->with($uri)->will($this->returnValue($siteAccessUri . $uri));
         $siteAccess->matcher = $matcher;
     }
     $urlGenerator = $this->getMock('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface');
     $httpUtils = new HttpUtils($urlGenerator);
     $httpUtils->setSiteAccess($siteAccess);
     $request = Request::create('http://ezpublish.dev/');
     $request->attributes->set('siteaccess', $siteAccess);
     $requestAttributes = array('foo' => 'bar', 'some' => 'thing');
     $request->attributes->add($requestAttributes);
     if ($isUriRouteName) {
         $urlGenerator->expects($this->once())->method('generate')->with($uri, $requestAttributes, UrlGeneratorInterface::ABSOLUTE_URL)->will($this->returnValue($expected . '?' . http_build_query($requestAttributes)));
     }
     $res = $httpUtils->generateUri($request, $uri);
     $this->assertSame($expected, $res);
 }