Checks if passed URI has an excluded prefix, when a root location is defined.
public isUriPrefixExcluded ( string $uri ) : boolean | ||
$uri | string | |
return | boolean |
/** * Returns true of false on comparing $urlAlias->path and $path with case sensitivity. * * Used to determine if redirect is needed because requested path is case-different * from the stored one. * * @param \eZ\Publish\API\Repository\Values\Content\URLAlias $loadedUrlAlias * @param string $requestedPath * @param string $pathPrefix * * @return bool */ protected function needsCaseRedirect(URLAlias $loadedUrlAlias, $requestedPath, $pathPrefix) { // If requested path is excluded from tree root jail, compare it to loaded UrlAlias directly. if ($this->generator->isUriPrefixExcluded($requestedPath)) { return strcmp($loadedUrlAlias->path, $requestedPath) !== 0; } // Compare loaded UrlAlias with requested path, prefixed with configured path prefix. return strcmp($loadedUrlAlias->path, $pathPrefix . ($pathPrefix === '/' ? trim($requestedPath, '/') : rtrim($requestedPath, '/'))) !== 0; }
/** * @dataProvider providerTestIsPrefixExcluded */ public function testIsPrefixExcluded($uri, $expectedIsExcluded) { $this->urlAliasGenerator->setExcludedUriPrefixes(array('/products', '/shared/content', '/something/in-the-way/')); $this->assertSame($expectedIsExcluded, $this->urlAliasGenerator->isUriPrefixExcluded($uri)); }