eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Identifier\Section::matchLocation PHP Method

matchLocation() public method

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
return boolean
    public function matchLocation(Location $location)
    {
        $section = $this->repository->sudo(function (Repository $repository) use($location) {
            return $repository->getSectionService()->loadSection($location->getContentInfo()->sectionId);
        });
        return isset($this->values[$section->identifier]);
    }

Usage Example

Example #1
0
 /**
  * @dataProvider matchSectionProvider
  * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Identifier\Section::matchLocation
  * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig
  * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository
  *
  * @param string|string[] $matchingConfig
  * @param \eZ\Publish\API\Repository\Repository $repository
  * @param bool $expectedResult
  */
 public function testMatchLocation($matchingConfig, Repository $repository, $expectedResult)
 {
     $this->matcher->setRepository($repository);
     $this->matcher->setMatchingConfig($matchingConfig);
     $location = $this->getLocationMock();
     $location->expects($this->once())->method('getContentInfo')->will($this->returnValue($this->getContentInfoMock()));
     $this->assertSame($expectedResult, $this->matcher->matchLocation($location));
 }