1 | <?php |
||
19 | class RedirectDisplayer implements DisplayerInterface |
||
20 | { |
||
21 | /** |
||
22 | * The request instance. |
||
23 | * |
||
24 | * @var \Illuminate\Http\Request |
||
25 | */ |
||
26 | protected $request; |
||
27 | |||
28 | /** |
||
29 | * Create a new redirect displayer instance. |
||
30 | * |
||
31 | * @param \Illuminate\Http\Request $request |
||
32 | */ |
||
33 | public function __construct(Request $request) |
||
37 | |||
38 | /** |
||
39 | * Get the error response associated with the given exception. |
||
40 | * |
||
41 | * @param \Exception $exception |
||
42 | * @param string $id |
||
43 | * @param int $code |
||
44 | * @param string[] $headers |
||
45 | * |
||
46 | * @return \Symfony\Component\HttpFoundation\Response |
||
47 | */ |
||
48 | public function display(Exception $exception, $id, $code, array $headers) |
||
52 | |||
53 | /** |
||
54 | * Get the supported content type. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | public function contentType() |
||
62 | |||
63 | /** |
||
64 | * Can we display the exception? |
||
65 | * |
||
66 | * @param \Exception $original |
||
67 | * @param \Exception $transformed |
||
68 | * @param int $code |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | public function canDisplay(Exception $original, Exception $transformed, $code) |
||
73 | { |
||
74 | $redirect = $transformed instanceof HttpExceptionInterface && $transformed->getStatusCode() === 401; |
||
75 | |||
76 | return $redirect && ! $this->request->is('api*'); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Do we provide verbose information about the exception? |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function isVerbose() |
||
88 | } |
||
89 |