Skip to content

Commit

Permalink
minor #1967 Mark deprecated since Symfony 4.2 for Controller (phamuye…
Browse files Browse the repository at this point in the history
…ntri)

This PR was squashed before being merged into the 2.4-dev branch (closes #1967).

Discussion
----------

Mark deprecated since Symfony 4.2 for Controller

Create new `AbstractFOSRestController` and mark `FOSRestController` as deprecated because `Symfony\Bundle\FrameworkBundle\Controller\Controller` is deprecated in Symfony 4.2

Commits
-------

d84adf0 Mark deprecated since Symfony 4.2 for Controller
  • Loading branch information
xabbuh committed Dec 9, 2018
2 parents 8fd0097 + d84adf0 commit 775c14b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Controller/AbstractFOSRestController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
* This file is part of the FOSRestBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\RestBundle\Controller;

use FOS\RestBundle\View\ViewHandlerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

/**
* Controllers using the View functionality of FOSRestBundle.
*/
abstract class AbstractFOSRestController extends AbstractController
{
use ControllerTrait;

/**
* Get the ViewHandler.
*
* @return ViewHandlerInterface
*/
protected function getViewHandler()
{
if (!$this->viewhandler instanceof ViewHandlerInterface) {
$this->viewhandler = $this->container->get('fos_rest.view_handler');
}

return $this->viewhandler;
}

/**
* {@inheritdoc}
*
* @return array
*/
public static function getSubscribedServices()
{
$subscribedServices = parent::getSubscribedServices();
$subscribedServices['fos_rest.view_handler'] = ViewHandlerInterface::class;

return $subscribedServices;
}
}
2 changes: 2 additions & 0 deletions Controller/FOSRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
/**
* Controllers using the View functionality of FOSRestBundle.
*
* @deprecated since FOSRestBundle 2.5, use {@see AbstractFOSRestController} instead
*
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
*/
abstract class FOSRestController extends Controller
Expand Down

0 comments on commit 775c14b

Please sign in to comment.