1 | <?php |
||
11 | final class RouteManager |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * @var array|Route[] |
||
16 | */ |
||
17 | private $routes; |
||
18 | |||
19 | /** |
||
20 | * @var \DoliDB |
||
21 | */ |
||
22 | private $db; |
||
23 | |||
24 | /** |
||
25 | * @var Guard[]|array |
||
26 | */ |
||
27 | private $guards; |
||
28 | |||
29 | public function __construct(\DoliDB $db) |
||
34 | |||
35 | |||
36 | /** |
||
37 | * @param Route $route |
||
38 | * |
||
39 | * @throws \Exception |
||
40 | */ |
||
41 | public function add(Route $route){ |
||
48 | |||
49 | /** |
||
50 | * @param array $routes |
||
51 | * |
||
52 | * @throws \Exception |
||
53 | */ |
||
54 | public function load(array $routes){ |
||
59 | |||
60 | /** |
||
61 | * @param array|Guard[] $routesGuards |
||
62 | */ |
||
63 | public function loadGuards($routesGuards) |
||
69 | |||
70 | /** |
||
71 | * Is the user authorized to reach the endpoint? |
||
72 | * @param User $user |
||
73 | * @param $routeName |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function isAuthorized(User $user, $routeName){ |
||
83 | |||
84 | /** |
||
85 | * @param string $name |
||
86 | * |
||
87 | * @param User $user |
||
88 | * |
||
89 | * @return Redirect|Response |
||
90 | * |
||
91 | * @throws \Exception |
||
92 | */ |
||
93 | public function __invoke($name, User $user) |
||
110 | |||
111 | |||
112 | } |