cgView->viewPath = APP_DIR . "/modules/module_shop/views/"; $this->moduleShopService = new ModuleShopService(); } public function actionCreate(): void { $this->cgView->render("form.php"); } #[NoReturn] public function actionAdd(): void { $moduleShopForm = new CreateModuleShopForm(); $moduleShopForm->load($_REQUEST); if ($moduleShopForm->validate()) { $module = $this->moduleShopService->create($moduleShopForm); if ($module) { $this->redirect("/admin/module_shop/" . $module->id); } } $this->redirect("/admin/module_shop/create"); } public function actionIndex(int $page_number = 1): void { $this->cgView->render("index.php", ['page_number' => $page_number]); } public function actionView(int $id): void { $module = ModuleShop::find($id); if (!$module) { throw new Exception("The module not found"); } $this->cgView->render("view.php", ['module' => $module]); } public function actionUpdate(int $id): void { $model = ModuleShop::find($id); if (!$model) { throw new Exception("The module not found"); } $this->cgView->render("form.php", ['model' => $model]); } public function actionEdit(int $id): void { $module = ModuleShop::find($id); if (!$module) { throw new Exception("The module not found"); } $moduleForm = new CreateModuleShopForm(); $moduleForm->load($_REQUEST); if ($moduleForm->validate()) { $module = $this->moduleShopService->update($moduleForm, $module); if ($module) { $this->redirect("/admin/module_shop/" . $module->id); } } $this->redirect("/admin/module_shop/update/" . $id); } public function actionDelete(int $id): void { $module = ModuleShop::find($id); if (!$module) { throw new Exception("The module not found"); } $module->delete(); $this->redirect("/admin/module_shop"); } public function actionPack(int $id): void { $module = ModuleShop::find($id); if (!$module) { throw new Exception("The module not found"); } $this->moduleShopService->packModule($module); } }