Completed
Push — EZP-31110 ( 682d94...63ed61 )
by
unknown
20:06
created

UrlAliasRouter::getUrlAlias()   A

Complexity

Conditions 5
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 2
nop 2
dl 0
loc 15
rs 9.4555
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Bundle\EzPublishCoreBundle\Routing;
8
9
use eZ\Publish\Core\MVC\ConfigResolverInterface;
10
use eZ\Publish\Core\MVC\Symfony\Routing\UrlAliasRouter as BaseUrlAliasRouter;
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
13
14
class UrlAliasRouter extends BaseUrlAliasRouter
15
{
16
    /** @var \eZ\Publish\Core\MVC\ConfigResolverInterface; */
17
    protected $configResolver;
18
19
    /**
20
     * @param ConfigResolverInterface $configResolver
21
     */
22
    public function setConfigResolver(ConfigResolverInterface $configResolver)
23
    {
24
        $this->configResolver = $configResolver;
25
    }
26
27
    public function matchRequest(Request $request)
28
    {
29
        // UrlAliasRouter might be disabled from configuration.
30
        // An example is for running the admin interface: it needs to be entirely run through the legacy kernel.
31
        if ($this->configResolver->getParameter('url_alias_router') === false) {
32
            throw new ResourceNotFoundException('Config says to bypass UrlAliasRouter');
33
        }
34
35
        return parent::matchRequest($request);
36
    }
37
}
38