Completed
Push — ezp25003-trash_subitems_count_... ( c4ee15...9f71a1 )
by
unknown
60:38 queued 26:57
created

ServiceAwareMatcherFactory::setContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
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\ContainerInterface;
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
    /**
20
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
21
     */
22
    private $container;
23
24
    public function setContainer(ContainerInterface $container = null)
25
    {
26
        $this->container = $container;
27
    }
28
29
    /**
30
     * @param string $matcherIdentifier
31
     *
32
     * @return \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MatcherInterface
33
     */
34
    protected function getMatcher($matcherIdentifier)
35
    {
36
        if ($this->container->has($matcherIdentifier)) {
37
            return $this->container->get($matcherIdentifier);
38
        }
39
40
        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 40 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...
41
    }
42
}
43