-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #1967 Mark deprecated since Symfony 4.2 for Controller (phamuye…
…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
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters