Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Addon::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['GridView.pagination.pageSize']]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['status' => $this->status, 'installed' => $this->installed]);
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'class', $this->class])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'version', $this->version])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Run DB Migration Down
  *
  * @return \yii\web\Response
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionUninstall()
 {
     $addOns = Addon::findAll(['id' => Yii::$app->getRequest()->post('ids')]);
     if (empty($addOns)) {
         throw new NotFoundHttpException(Yii::t('addon', 'Page not found.'));
     } else {
         foreach ($addOns as $addOn) {
             // Run Addon DB Migration
             $migrationPath = Yii::getAlias('@addons') . DIRECTORY_SEPARATOR . $addOn->id . DIRECTORY_SEPARATOR . 'migrations';
             if (is_dir($migrationPath)) {
                 ConsoleHelper::migrateDown($migrationPath, 'migration_' . $addOn->id);
             }
             $addOn->status = $addOn::STATUS_INACTIVE;
             $addOn->installed = $addOn::INSTALLED_OFF;
             $addOn->update();
         }
         Yii::$app->getSession()->setFlash('success', Yii::t('addon', 'The selected items have been uninstalled successfully.'));
         return $this->redirect(['index']);
     }
 }
Пример #3
0
 protected function getActiveAddOns()
 {
     $activeAddOns = ArrayHelper::map(Addon::find()->active()->all(), 'id', 'class');
     $addOns = [];
     foreach ($activeAddOns as $id => $class) {
         $addOns[$id]['class'] = $class;
     }
     return $addOns;
 }