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 Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; |
15
|
|
|
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; |
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
17
|
|
|
|
18
|
|
|
abstract class TemplatingExceptionController extends ExceptionController |
19
|
|
|
{ |
20
|
|
|
protected $templating; |
21
|
|
|
|
22
|
|
|
public function __construct( |
23
|
|
|
ExceptionWrapperHandlerInterface $exceptionWrapperHandler, |
24
|
|
|
FormatNegotiator $formatNegotiator, |
25
|
|
|
ViewHandlerInterface $viewHandler, |
26
|
|
|
array $exceptionCodes, |
27
|
|
|
array $exceptionMessages, |
28
|
|
|
$showException, |
29
|
|
|
EngineInterface $templating |
30
|
|
|
) { |
31
|
|
|
parent::__construct($exceptionWrapperHandler, $formatNegotiator, $viewHandler, $exceptionCodes, $exceptionMessages, $showException); |
32
|
|
|
|
33
|
|
|
$this->templating = $templating; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Finds the template for the given format and status code. |
38
|
|
|
* |
39
|
|
|
* @param Request $request |
40
|
|
|
* @param string $format |
41
|
|
|
* @param int $statusCode |
42
|
|
|
* @param bool $showException |
43
|
|
|
* |
44
|
|
|
* @return TemplateReference |
45
|
|
|
*/ |
46
|
|
|
abstract protected function findTemplate(Request $request, $format, $statusCode, $showException); |
47
|
|
|
} |
48
|
|
|
|