eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::matchLocation PHP Метод

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

Checks if a Location object matches.
public matchLocation ( eZ\Publish\API\Repository\Values\Content\Location $location ) : boolean
$location eZ\Publish\API\Repository\Values\Content\Location
Результат boolean
    public function matchLocation(Location $location)
    {
        $urlAliasService = $this->repository->getURLAliasService();
        $locationUrls = array_merge($urlAliasService->listLocationAliases($location), $urlAliasService->listLocationAliases($location, false));
        foreach ($this->values as $pattern => $val) {
            foreach ($locationUrls as $urlAlias) {
                if (strpos($urlAlias->path, "/{$pattern}") === 0) {
                    return true;
                }
            }
        }
        return false;
    }

Usage Example

 /**
  * @dataProvider matchLocationProvider
  * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::matchLocation
  * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::setMatchingConfig
  * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository
  *
  * @param string|string[] $matchingConfig
  * @param \eZ\Publish\API\Repository\Repository $repository
  * @param boolean $expectedResult
  *
  * @return void
  */
 public function testMatchLocation($matchingConfig, Repository $repository, $expectedResult)
 {
     $this->matcher->setRepository($repository);
     $this->matcher->setMatchingConfig($matchingConfig);
     $this->assertSame($expectedResult, $this->matcher->matchLocation($this->getLocationMock()));
 }