/** * Edit a category */ public function edit() { if (isset($_SESSION['login']) && $_SESSION['login'] === true) { if (!empty(func_get_args())) { $this->params = func_get_args()[0]; if (!empty($this->params)) { $this->params = $this->params[0]; } } if (!preg_match('/[0-9]+$/', $this->params, $int)) { $this->redirectTo('posts'); } $this->idOfEditedPage = $int[0]; $this->category = Model::getOneFrom('categories', $int[0]); $this->categories = Model::getAllFrom('categories'); $this->render('categories/edit'); } else { $this->redirectTo('categories/index'); } }