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
|
2 |
|
return new static(lang('Router.invalidParameterType')); |
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 lorsque la route n'est pas valide. |
52
|
|
|
* |
53
|
|
|
* @return RouterException |
54
|
|
|
*/ |
55
|
|
|
public static function invalidRoute(string $route) |
56
|
|
|
{ |
57
|
|
|
return new static(lang('HTTP.invalidRoute', [$route])); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Throw when dynamic controller. |
62
|
|
|
* |
63
|
|
|
* @return RouterException |
64
|
|
|
*/ |
65
|
|
|
public static function dynamicController(string $handler) |
66
|
|
|
{ |
67
|
2 |
|
return new static(lang('Router.invalidDynamicController', [$handler])); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Throw when controller name has `/`. |
72
|
|
|
* |
73
|
|
|
* @return RouterException |
74
|
|
|
*/ |
75
|
|
|
public static function invalidControllerName(string $handler) |
76
|
|
|
{ |
77
|
2 |
|
return new static(lang('Router.invalidControllerName', [$handler])); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|