Beispiel #1
0
 /**
  * @return ModuleModel
  */
 private function getModule()
 {
     /** @var ModuleModel $module */
     $module = ModuleModel::findOne(['name' => $this->module->id]);
     if (is_null($module)) {
         $module = new ModuleModel();
     }
     return $module;
 }
Beispiel #2
0
 public function beforeAction($action)
 {
     $moduleName = $this->id;
     /** @var \app\module\module\models\Module $moduleInstalled */
     $moduleInstalled = \app\module\module\models\Module::findOne(['name' => $moduleName]);
     if (is_null($moduleInstalled) || $moduleInstalled->isEnabled() == false) {
         throw new NotFoundHttpException(sprintf('Module %s not installed or disabled', $moduleName));
     }
     return true;
 }
 public function init()
 {
     $moduleName = $this->module->id;
     /** @var Module $module */
     $this->currentModule = Module::findOne(['name' => $moduleName]);
     if ($this->needAuthentication() == false) {
         return true;
     }
     if (\Yii::$app->user->isGuest) {
         \Yii::$app->user->setReturnUrl(\Yii::$app->request->url);
         $this->addMessage('user', 'restricted_area', Message::ALERT);
         $this->redirect('/admin/user/auth/login');
         return false;
     }
     $this->checkModuleAccess();
     //		$this->checkAdminAccess();
     /** @var Module $menuItem */
     foreach (ModuleQuery::findAllOrdered() as $menuItem) {
         $this->menuItems[$menuItem->category_name][] = $menuItem;
     }
     \Yii::$app->layout = 'admin.tpl';
 }
 public function actionUpdate($id)
 {
     /** @var Module $module */
     $module = Module::findOne(['id' => $id]);
     if (is_null($module)) {
         $this->addMessage('module', 'module_not_found', Message::ALERT);
         return $this->redirect('/admin/module');
     }
     $transaction = \Yii::$app->getDb()->beginTransaction();
     try {
         $installator = new BaseInstallator(\Yii::$app->getModule($module->name));
         $installator->runWithData();
         $transaction->commit();
         $this->addMessage('module', sprintf('Module %s was succesfull updated', $module->name), Message::INFO);
     } catch (ModuleInstallatorNotFound $e) {
         $transaction->rollBack();
         $this->addMessage('module', 'instalator_not_found', Message::ALERT);
     } catch (InstallFailedException $e) {
         $transaction->rollBack();
         $message = sprintf("<pre>%s</pre>", $e->getMessage());
         $message = sprintf("`module.uninstall_error_with_message` \n %s", $message);
         $this->addMessage(null, $message, Message::ALERT);
     }
     return $this->redirect('/admin/module');
 }