eZ\Publish\Core\MVC\Symfony\Matcher\AbstractMatcherFactory::getMatcher PHP Method

getMatcher() protected method

Returns the matcher object.
protected getMatcher ( string $matcherIdentifier ) : eZ\Publish\Core\MVC\Symfony\Matcher\MatcherInterface | eZ\Publish\Core\MVC\Symfony\Matcher\ViewMatcherInterface
$matcherIdentifier string The matcher class. If it begins with a '\' it means it's a FQ class name, otherwise it is relative to static::MATCHER_RELATIVE_NAMESPACE namespace (if available).
return eZ\Publish\Core\MVC\Symfony\Matcher\MatcherInterface | eZ\Publish\Core\MVC\Symfony\Matcher\ViewMatcherInterface
    protected function getMatcher($matcherIdentifier)
    {
        // Not a FQ class name, so take the relative namespace.
        if ($matcherIdentifier[0] !== '\\' && defined('static::MATCHER_RELATIVE_NAMESPACE')) {
            $matcherIdentifier = static::MATCHER_RELATIVE_NAMESPACE . "\\{$matcherIdentifier}";
        }
        // Retrieving the matcher instance from in-memory cache
        if (isset($this->matchers[$matcherIdentifier])) {
            return $this->matchers[$matcherIdentifier];
        }
        if (!class_exists($matcherIdentifier)) {
            throw new InvalidArgumentException("Invalid matcher class '{$matcherIdentifier}'");
        }
        $this->matchers[$matcherIdentifier] = new $matcherIdentifier();
        if ($this->matchers[$matcherIdentifier] instanceof RepositoryAwareInterface) {
            $this->matchers[$matcherIdentifier]->setRepository($this->repository);
        }
        return $this->matchers[$matcherIdentifier];
    }

Usage Example

 protected function getMatcher($matcherIdentifier)
 {
     $matcher = parent::getMatcher($matcherIdentifier);
     if (!$matcher instanceof BlockMatcherInterface) {
         throw new InvalidArgumentException('Matcher for Blocks must implement eZ\\Publish\\Core\\MVC\\Symfony\\Matcher\\Block\\MatcherInterface.');
     }
     return $matcher;
 }
All Usage Examples Of eZ\Publish\Core\MVC\Symfony\Matcher\AbstractMatcherFactory::getMatcher