示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ModuleModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'backend_bootstrap' => $this->backend_bootstrap, 'frontend_bootstrap' => $this->frontend_bootstrap, 'date' => $this->date, 'modified' => $this->modified]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'config', $this->config])->andFilterWhere(['like', 'directory', $this->directory]);
     return $dataProvider;
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ModuleModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'module_status' => $this->module_status, 'module_bb' => $this->module_bb, 'module_fb' => $this->module_fb, 'module_date' => $this->module_date, 'module_modified' => $this->module_modified]);
     $query->andFilterWhere(['like', 'module_name', $this->module_name])->andFilterWhere(['like', 'module_title', $this->module_title])->andFilterWhere(['like', 'module_description', $this->module_description])->andFilterWhere(['like', 'module_config', $this->module_config])->andFilterWhere(['like', 'module_dir', $this->module_dir]);
     return $dataProvider;
 }
示例#3
0
 /**
  * Set modules.
  *
  * @param Application $app the application currently running
  */
 protected function setModule($app)
 {
     foreach (Module::getActiveModules() as $module) {
         // Get module backend config.
         if ($moduleConfig = $module->backendConfig) {
             // Set module.
             $app->setModules([$module->module_name => $moduleConfig]);
             // Merge application params with exist module params.
             if (is_file($module->paramPath)) {
                 $moduleParam = (require $module->paramPath);
                 if (isset($moduleParam['backend'])) {
                     $app->params = ArrayHelper::merge($app->params, $moduleParam['backend']);
                 }
             }
             // Bootstrap injection.
             if ($module->module_fb) {
                 $component = $app->getModule($module->module_name);
                 if ($component instanceof BootstrapInterface) {
                     $component->bootstrap($app);
                 }
             }
         }
     }
 }
示例#4
0
 /**
  * Set modules.
  *
  * @param Application $app the application currently running
  */
 protected function setModule($app)
 {
     foreach (Module::getActiveModules() as $module) {
         // Get module backend config.
         if ($config = $module->getFrontendConfig()) {
             // Set module.
             $app->setModules([$module->name => $config]);
             // Merge application params with exist module params.
             if (is_file($module->getParamPath())) {
                 $params = (require $module->getParamPath());
                 if ($frontendParams = ArrayHelper::getValue($params, 'frontend')) {
                     $app->params = ArrayHelper::merge($app->params, $frontendParams);
                 }
             }
             // Bootstrap injection.
             if ($module->frontend_bootstrap) {
                 $component = $app->getModule($module->name);
                 if ($component instanceof BootstrapInterface) {
                     $component->bootstrap($app);
                 }
             }
         }
     }
 }
示例#5
0
 /**
  * Finds the Module model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id
  *
  * @return Module the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Module::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#6
0
 /**
  * @param FunctionalTester $I
  */
 public function testUpdate(FunctionalTester $I)
 {
     $I->wantTo('ensure that update page works');
     $updatePage = UpdatePage::openBy($I);
     $I->see('Update Module: sitemap', 'h1');
     $I->seeLink('Basic', '#');
     $I->seeLink('Frontend', '#');
     $I->seeLink('Backend', '#');
     $I->amGoingTo('submit update module form with correct data');
     $I->checkOption('#module-module_status');
     $updatePage->submit(['module_name' => 'test', 'module_title' => 'Test']);
     $I->expect('module updated');
     $I->see('Modules', 'h1');
     $I->see('Test', '#module-grid-view');
     Module::findOne(2)->updateAttributes(['module_name' => 'sitemap', 'module_title' => 'Sitemap', 'module_status' => '0']);
 }
示例#7
0
 /**
  * Finds the Module model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id
  * @return Module the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Module::findOne($id)) !== null) {
         return $model;
     }
     throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.'));
 }