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]); } public function actionSettings(): void { $this->cgView->render('settingsForm.php'); } #[NoReturn] public function actionSaveSettings(): void { $request = new Request(); $entities = $request->post('entity'); EntityRelation::configurationEntitiesByProperty($entities, 'photo'); Flash::setMessage("success", "Настройка прошла успешно"); $this->redirect("/admin/settings/photo", 302); } }