/** * 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']); } }