cgView->viewPath = KERNEL_APP_MODULES_DIR . "/photo/views/"; $this->photoService = new PhotoService(); } public function actionCreate(): void { $this->cgView->render("form.php"); } #[NoReturn] public function actionAdd(): void { $photoForm = new CreatePhotoForm(); $photoForm->load($_REQUEST); if ($photoForm->validate()){ $photo = $this->photoService->create($photoForm); if ($photo){ $this->redirect("/admin/photo/view/" . $photo->id); } } $this->redirect("/admin/photo/create"); } public function actionIndex($page_number = 1): void { $this->cgView->render("index.php", ['page_number' => $page_number]); } /** * @throws Exception */ public function actionView($id): void { $photo = Photo::find($id); if (!$photo){ throw new Exception(message: "The photo not found"); } $this->cgView->render("view.php", ['photo' => $photo]); } // /** // * @throws Exception // */ // public function actionUpdate($id): void // { // $model = Tag::find($id); // if (!$model){ // throw new Exception(message: "The tag not found"); // } // // $this->cgView->render("form.php", ['model' => $model]); // } // // /** // * @throws Exception // */ // public function actionEdit($id): void // { // $tag = Tag::find($id); // if (!$tag){ // throw new Exception(message: "The tag not found"); // } // $tagForm = new CreateTagForm(); // $tagService = new TagService(); // $tagForm->load($_REQUEST); // if ($tagForm->validate()) { // $tag = $tagService->update($tagForm, $tag); // if ($tag) { // $this->redirect("/admin/tag/view/" . $tag->id); // } // } // $this->redirect("/admin/tag/update/" . $id); // } // // #[NoReturn] public function actionDelete($id): void // { // $post = Tag::find($id)->first(); // $post->delete(); // $this->redirect("/admin/tag/"); // } // // public function actionSettings(): void // { // $this->cgView->render('form.php'); // } }