cgView->viewPath = KERNEL_APP_MODULES_DIR . "/ЕÑtest/views/"; $this->ЕÑtestService = new ЕÑtestService(); } public function actionCreate(): void { $this->cgView->render("form.php"); } #[NoReturn] public function actionAdd(): void { $ЕÑtestForm = new CreateЕÑtestForm(); $ЕÑtestForm->load($_REQUEST); if ($ЕÑtestForm->validate()){ $ЕÑtest = $this->ЕÑtestService->create($ЕÑtestForm); if ($ЕÑtest){ $this->redirect("/admin/ЕÑtest/view/" . $ЕÑtest->id); } } $this->redirect("/admin/ЕÑtest/create"); } public function actionIndex($page_number = 1): void { $this->cgView->render("index.php", ['page_number' => $page_number]); } /** * @throws Exception */ public function actionView($id): void { $ЕÑtest = ЕÑtest::find($id); if (!$ЕÑtest){ throw new Exception(message: "The ЕÑtest not found"); } $this->cgView->render("view.php", ['ЕÑtest' => $ЕÑtest]); } /** * @throws Exception */ public function actionUpdate($id): void { $model = ЕÑtest::find($id); if (!$model){ throw new Exception(message: "The ЕÑtest not found"); } $this->cgView->render("form.php", ['model' => $model]); } /** * @throws Exception */ public function actionEdit($id): void { $ЕÑtest = ЕÑtest::find($id); if (!$ЕÑtest){ throw new Exception(message: "The ЕÑtest not found"); } $ЕÑtestForm = new CreateЕÑtestForm(); $ЕÑtestService = new ЕÑtestService(); $ЕÑtestForm->load($_REQUEST); if ($ЕÑtestForm->validate()) { $ЕÑtest = $ЕÑtestService->update($ЕÑtestForm, $ЕÑtest); if ($ЕÑtest) { $this->redirect("/admin/ЕÑtest/view/" . $ЕÑtest->id); } } $this->redirect("/admin/ЕÑtest/update/" . $id); } #[NoReturn] public function actionDelete($id): void { $ЕÑtest = ЕÑtest::find($id)->first(); $ЕÑtest->delete(); $this->redirect("/admin/ЕÑtest/"); } }