vendor/friendsofsymfony/rest-bundle/Controller/AbstractFOSRestController.php line 32

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