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\StepupRa\RaBundle\Controller; |
20
|
|
|
|
21
|
|
|
use Exception; |
22
|
|
|
use Surfnet\StepupBundle\Controller\ExceptionController as BaseExceptionController; |
23
|
|
|
use Surfnet\StepupRa\RaBundle\Exception\LoaTooLowException; |
24
|
|
|
use Surfnet\StepupRa\RaBundle\Exception\MissingRequiredAttributeException; |
25
|
|
|
use Surfnet\StepupRa\RaBundle\Exception\UserNotRaException; |
26
|
|
|
|
27
|
|
|
final class ExceptionController extends BaseExceptionController |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @param Exception $exception |
31
|
|
|
* @return array View parameters 'title' and 'description' |
32
|
|
|
*/ |
33
|
|
|
protected function getPageTitleAndDescription(Exception $exception) |
34
|
|
|
{ |
35
|
|
|
$translator = $this->getTranslator(); |
36
|
|
|
|
37
|
|
|
if ($exception instanceof UserNotRaException) { |
38
|
|
|
$title = $translator->trans('stepup.error.user_not_ra.title'); |
39
|
|
|
$description = $translator->trans('stepup.error.user_not_ra.description'); |
40
|
|
|
|
41
|
|
|
} elseif ($exception instanceof LoaTooLowException) { |
42
|
|
|
$title = $translator->trans('stepup.error.loa_too_low.title'); |
43
|
|
|
$description = $translator->trans('stepup.error.loa_too_low.description'); |
44
|
|
|
|
45
|
|
|
} elseif ($exception instanceof MissingRequiredAttributeException) { |
46
|
|
|
$title = $translator->trans('stepup.error.missing_required_attribute.title'); |
47
|
|
|
$description = $exception->getMessage(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if (isset($title) && isset($description)) { |
51
|
|
|
return [ |
52
|
|
|
'title' => $title, |
53
|
|
|
'description' => $description, |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return parent::getPageTitleAndDescription($exception); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|