eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement::analyseURI PHP Méthode

analyseURI() public méthode

Analyses $uri and removes the siteaccess part, if needed.
public analyseURI ( string $uri ) : string
$uri string The original URI
Résultat string The modified URI
    public function analyseURI($uri)
    {
        $uriElements = '/' . implode('/', $this->getURIElements());
        if ($uri == $uriElements) {
            $uri = '';
        } elseif (strpos($uri, $uriElements) === 0) {
            $uri = mb_substr($uri, mb_strlen($uriElements));
        }
        return $uri;
    }

Usage Example

 /**
  * @param string $uri
  * @param string $expectedFixedUpURI
  *
  * @dataProvider analyseProvider
  */
 public function testAnalyseURI($uri, $expectedFixedUpURI)
 {
     $matcher = new URIElementMatcher(1);
     $matcher->setRequest(new SimplifiedRequest(array('pathinfo' => $uri)));
     $this->assertSame($expectedFixedUpURI, $matcher->analyseURI($uri));
 }