|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Blitz PHP framework. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2022 Dimitri Sitchet Tomkeu <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view |
|
9
|
|
|
* the LICENSE file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace BlitzPHP\Exceptions; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* RouterException |
|
16
|
|
|
*/ |
|
17
|
|
|
class RouterException extends FrameworkException |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* Levé lorsque le type de paramètre réel ne correspond pas |
|
21
|
|
|
* les types attendus. |
|
22
|
|
|
* |
|
23
|
|
|
* @return RouterException |
|
24
|
|
|
*/ |
|
25
|
|
|
public static function invalidParameterType() |
|
26
|
|
|
{ |
|
27
|
4 |
|
return new static(lang('Router.invalidParameter')); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Levée lorsqu'une route par défaut n'est pas définie. |
|
32
|
|
|
* |
|
33
|
|
|
* @return RouterException |
|
34
|
|
|
*/ |
|
35
|
|
|
public static function missingDefaultRoute() |
|
36
|
|
|
{ |
|
37
|
|
|
return new static(lang('Router.missingDefaultRoute')); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Lancer lorsque le contrôleur ou sa méthode est introuvable. |
|
42
|
|
|
* |
|
43
|
|
|
* @return RouterException |
|
44
|
|
|
*/ |
|
45
|
|
|
public static function controllerNotFound(string $controller, string $method) |
|
46
|
|
|
{ |
|
47
|
|
|
return new static(lang('HTTP.controllerNotFound', [$controller, $method])); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Lancer lorsqu'une action (contrôleur + méthode) n'a pas etee definie dans les routes. |
|
52
|
|
|
* |
|
53
|
|
|
* @return RouterException |
|
54
|
|
|
*/ |
|
55
|
|
|
public static function actionNotDefined(string $action) |
|
56
|
|
|
{ |
|
57
|
2 |
|
return new static(lang('Router.actionNotDefined', [$action])); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Lancer lorsque la route n'est pas valide. |
|
62
|
|
|
* |
|
63
|
|
|
* @return RouterException |
|
64
|
|
|
*/ |
|
65
|
|
|
public static function invalidRoute(string $route) |
|
66
|
|
|
{ |
|
67
|
|
|
return new static(lang('HTTP.invalidRoute', [$route])); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Throw when dynamic controller. |
|
72
|
|
|
* |
|
73
|
|
|
* @return RouterException |
|
74
|
|
|
*/ |
|
75
|
|
|
public static function dynamicController(string $handler) |
|
76
|
|
|
{ |
|
77
|
2 |
|
return new static(lang('Router.invalidDynamicController', [$handler])); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Throw when controller name has `/`. |
|
82
|
|
|
* |
|
83
|
|
|
* @return RouterException |
|
84
|
|
|
*/ |
|
85
|
|
|
public static function invalidControllerName(string $handler) |
|
86
|
|
|
{ |
|
87
|
2 |
|
return new static(lang('Router.invalidControllerName', [$handler])); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|