1 | <?php |
||
13 | class Router |
||
14 | { |
||
15 | /** @var \Opis\Pattern\RegexBuilder */ |
||
16 | protected $builder; |
||
17 | |||
18 | /** @var array */ |
||
19 | protected $routes = []; |
||
20 | |||
21 | /** @var \LBHurtado\Missive\Missive */ |
||
22 | public $missive; |
||
23 | |||
24 | /** @var ContainerInterface */ |
||
25 | protected $container; |
||
26 | |||
27 | /** |
||
28 | * Router constructor. |
||
29 | * Capture the Missive instance from the container. |
||
30 | * Instantiate RegexBuilder that ignores casing. |
||
31 | * |
||
32 | * @param Missive $missive |
||
33 | */ |
||
34 | public function __construct(Missive $missive) |
||
42 | |||
43 | /** |
||
44 | * @param string $route |
||
45 | * @param string|callable $action |
||
46 | * @return Router |
||
47 | */ |
||
48 | public function register(string $route, $action): self |
||
56 | |||
57 | /** |
||
58 | * Sets the SMS property of Missive before |
||
59 | * executing the contents of them sms |
||
60 | * |
||
61 | * @param SMSAbstract $sms |
||
62 | * @return bool |
||
63 | * @throws Exception |
||
64 | */ |
||
65 | public function process(SMSAbstract $sms) |
||
71 | |||
72 | |||
73 | /** |
||
74 | * Return true if handled. |
||
75 | * Otherwise, send to next route. |
||
76 | * |
||
77 | * @param string $path |
||
78 | * @return bool |
||
79 | * @throws Exception |
||
80 | */ |
||
81 | public function execute(string $path) |
||
98 | |||
99 | /** |
||
100 | * Make sure to rollback the database if an error occurs. |
||
101 | * |
||
102 | * @param $action |
||
103 | * @param $path |
||
104 | * @param $values |
||
105 | * @return bool |
||
106 | * @throws Exception |
||
107 | */ |
||
108 | protected function do($action, $path, $values) |
||
125 | |||
126 | /** |
||
127 | * Make an action for an invokable controller. |
||
128 | * |
||
129 | * @param string $action |
||
130 | * @return string |
||
131 | * @throws UnexpectedValueException |
||
132 | */ |
||
133 | protected function makeInvokableAction($action) |
||
143 | |||
144 | /** |
||
145 | * @param $callback |
||
146 | * @return array|string|Closure |
||
147 | * @throws UnexpectedValueException |
||
148 | * @throws NotFoundExceptionInterface |
||
149 | */ |
||
150 | protected function getCallable($callback) |
||
174 | |||
175 | /** |
||
176 | * @param ContainerInterface $container |
||
177 | */ |
||
178 | public function setContainer(ContainerInterface $container) |
||
182 | } |
||
183 |