getCategoryAccessChecker()->canChange($id)) { throw new Forbidden(); } $category = $this->getCategoryRepository()->get($id); if ($this->request->isPost()) { $this->validatePostRequest(['name' => 'required|length_between:1,64']); $user = $this->getAuth()->getUserFromSession(); $category->edit($_POST['name'], $user->id); $this->response->redirect('/' . $category->slug); return; } $this->renderView(['category' => $category]); } private function getCategoryAccessChecker(): CategoryAccessChecker { return new CategoryAccessChecker(); } private function getAuth(): Auth { return new Auth(); } private function getCategoryRepository(): CategoryWriteRepository { return new CategoryWriteRepository(); } }