Completed
Push — ezp_30827 ( efb07b...c9282f )
by
unknown
28:57 queued 15:52
created

Controller::getSubscribedServices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
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
declare(strict_types=1);
8
9
namespace eZ\Bundle\EzPublishCoreBundle;
10
11
use eZ\Publish\API\Repository\Repository;
12
use eZ\Publish\API\Repository\Values\Content\Location;
13
use eZ\Publish\Core\MVC\ConfigResolverInterface;
14
use eZ\Publish\Core\MVC\Symfony\Templating\GlobalHelper;
15
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
16
17
class Controller extends AbstractController
18
{
19
    public function getRepository(): Repository
20
    {
21
        return $this->container->get('ezpublish.api.repository');
22
    }
23
24
    protected function getConfigResolver(): ConfigResolverInterface
25
    {
26
        return $this->container->get('ezpublish.config.resolver');
27
    }
28
29
    public function getGlobalHelper(): GlobalHelper
30
    {
31
        return $this->container->get('ezpublish.templating.global_helper');
32
    }
33
34
    /**
35
     * Returns the root location object for current siteaccess configuration.
36
     *
37
     * @return \eZ\Publish\API\Repository\Values\Content\Location
38
     */
39
    public function getRootLocation(): Location
40
    {
41
        return $this->getGlobalHelper()->getRootLocation();
42
    }
43
44
    public static function getSubscribedServices(): array
45
    {
46
        return array_merge(
47
            parent::getSubscribedServices(),
48
            [
49
                'ezpublish.api.repository' => Repository::class,
50
                'ezpublish.config.resolver' => ConfigResolverInterface::class,
51
                'ezpublish.templating.global_helper' => GlobalHelper::class,
52
            ]
53
        );
54
    }
55
}
56