Completed
Push — master ( 8fd009...775c14 )
by Christian
06:04
created

AbstractFOSRestController::getSubscribedServices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
     * Get the ViewHandler.
26
     *
27
     * @return ViewHandlerInterface
28
     */
29 View Code Duplication
    protected function getViewHandler()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        if (!$this->viewhandler instanceof ViewHandlerInterface) {
32
            $this->viewhandler = $this->container->get('fos_rest.view_handler');
33
        }
34
35
        return $this->viewhandler;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     *
41
     * @return array
42
     */
43
    public static function getSubscribedServices()
44
    {
45
        $subscribedServices = parent::getSubscribedServices();
46
        $subscribedServices['fos_rest.view_handler'] = ViewHandlerInterface::class;
47
48
        return $subscribedServices;
49
    }
50
}
51