Completed
Push — spi_getname_change ( 5d4921...c435e1 )
by André
23:05
created

ServiceAwareMatcherFactory::setContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * @license For full copyright and license information view LICENSE file distributed with this source code.
4
 */
5
namespace eZ\Bundle\EzPublishCoreBundle\Matcher;
6
7
use eZ\Publish\Core\MVC\Symfony\Matcher\ClassNameMatcherFactory;
8
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
10
11
/**
12
 * A view matcher factory that also accepts services as matchers.
13
 *
14
 * If a service id is passed as the MatcherIdentifier, this service will be used for the matching.
15
 * Otherwise, it will fallback to the class name based matcher factory.
16
 */
17
class ServiceAwareMatcherFactory extends ClassNameMatcherFactory implements ContainerAwareInterface
18
{
19
    use ContainerAwareTrait;
20
21
    /**
22
     * @param string $matcherIdentifier
23
     *
24
     * @return \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MatcherInterface
25
     */
26
    protected function getMatcher($matcherIdentifier)
27
    {
28
        if ($this->container->has($matcherIdentifier)) {
29
            return $this->container->get($matcherIdentifier);
30
        }
31
32
        return parent::getMatcher($matcherIdentifier);
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::getMatcher($matcherIdentifier); of type eZ\Publish\Core\MVC\Symf...er\ViewMatcherInterface adds the type eZ\Publish\Core\MVC\Symf...er\ViewMatcherInterface to the return on line 32 which is incompatible with the return type documented by eZ\Bundle\EzPublishCoreB...cherFactory::getMatcher of type eZ\Publish\Core\MVC\Symf...tBased\MatcherInterface.
Loading history...
33
    }
34
}
35