AbstractFOSRestController::getSubscribedServices()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\RestBundle\Controller;
13
14
use FOS\RestBundle\View\ViewHandlerInterface;
15
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
16
17
/**
18
 * Controllers using the View functionality of FOSRestBundle.
19
 */
20
abstract class AbstractFOSRestController extends AbstractController
21
{
22
    use ControllerTrait;
23
24
    /**
25
     * @return ViewHandlerInterface
26
     */
27
    protected function getViewHandler()
28
    {
29
        if (!$this->viewhandler instanceof ViewHandlerInterface) {
30
            $this->viewhandler = $this->container->get('fos_rest.view_handler');
31
        }
32
33
        return $this->viewhandler;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 12
    public static function getSubscribedServices()
40
    {
41 12
        $subscribedServices = parent::getSubscribedServices();
42 12
        $subscribedServices['fos_rest.view_handler'] = ViewHandlerInterface::class;
43
44 12
        return $subscribedServices;
45
    }
46
}
47