Completed
Push — 2.x ( d60e0b...09e01f )
by Guilhem
23s queued 10s
created

Controller/AbstractFOSRestController.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 View Code Duplication
    protected function getViewHandler()
0 ignored issues
show
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...
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 21
    public static function getSubscribedServices()
40
    {
41 21
        $subscribedServices = parent::getSubscribedServices();
42 21
        $subscribedServices['fos_rest.view_handler'] = ViewHandlerInterface::class;
43
44 21
        return $subscribedServices;
45
    }
46
}
47