1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2018 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupBundle\EventListener; |
20
|
|
|
|
21
|
|
|
use Symfony\Component\HttpFoundation\Request; |
22
|
|
|
use Symfony\Component\HttpKernel\EventListener\ExceptionListener as CoreExceptionListener; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Prepare the generic error page with detailed information for the user. |
26
|
|
|
*/ |
27
|
|
|
class ExceptionListener extends CoreExceptionListener |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Clones the request for the exception. |
31
|
|
|
* |
32
|
|
|
* Stepup-specific override: pass the original exception instead of the |
33
|
|
|
* FlattenException so we can show very speficic user messages in the |
34
|
|
|
* ExceptionController. |
35
|
|
|
* |
36
|
|
|
* @param \Exception $exception The thrown exception |
37
|
|
|
* @param Request $request The original request |
38
|
|
|
* |
39
|
|
|
* @return Request $request The cloned request |
40
|
|
|
*/ |
41
|
|
|
protected function duplicateRequest(\Exception $exception, Request $request) |
42
|
|
|
{ |
43
|
|
|
$attributes = array( |
44
|
|
|
'_controller' => $this->controller, |
45
|
|
|
'exception' => $exception, |
46
|
|
|
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, |
|
|
|
|
47
|
|
|
// keep for BC -- as $format can be an argument of the controller callable |
48
|
|
|
// see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php |
49
|
|
|
// @deprecated since version 2.4, to be removed in 3.0 |
50
|
|
|
'format' => $request->getRequestFormat(), |
51
|
|
|
); |
52
|
|
|
$request = $request->duplicate(null, null, $attributes); |
53
|
|
|
$request->setMethod('GET'); |
54
|
|
|
|
55
|
|
|
return $request; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.