| Conditions | 5 |
| Paths | 5 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function handle(array $params = []) |
||
| 15 | { |
||
| 16 | // Validar autenticación |
||
| 17 | if (Session::get("is_logged_in") !== true) { |
||
| 18 | Session::set("flash", "Debe iniciar sesión para acceder al recurso *<i>page</i>*"); |
||
| 19 | $this->redirect(""); |
||
| 20 | return; |
||
| 21 | } |
||
| 22 | |||
| 23 | // Determinar la acción basada en el método HTTP y parámetros |
||
| 24 | $action = $_SERVER['REQUEST_METHOD']; |
||
| 25 | $slug = $params[0] ?? ''; |
||
| 26 | |||
| 27 | if ($action === 'GET') { |
||
| 28 | if (isset($params[0])) { |
||
| 29 | // GET /page/show/{slug} |
||
| 30 | $this->show($slug); |
||
| 31 | } else { |
||
| 32 | // GET /page/edit |
||
| 33 | $this->edit(); |
||
| 34 | } |
||
| 35 | } elseif ($action === 'POST') { |
||
| 36 | // POST /page/update |
||
| 37 | $this->update(); |
||
| 38 | } |
||
| 67 |