beforeAction() public method

This method is invoked right before an action is to be executed (after all possible filters.) It checks the existence of the [[migrationPath]].
public beforeAction ( Action $action ) : boolean
$action yii\base\Action the action to be executed.
return boolean whether the action should continue to be executed.
 public function beforeAction($action)
 {
     $oldPath = $this->migrationPath;
     $this->migrationPath = $this->defaultMigrationPath;
     if (parent::beforeAction($action)) {
         $this->stdout('Migration files will be searched in folders: ' . PHP_EOL);
         $this->migrationPath = $oldPath;
         if ($this->moduleId) {
             $this->migrationPath = $this->getMigrationPath($this->moduleId);
         }
         if ($this->migrationPath) {
             $this->migrationPaths[] = $this->migrationPath;
         } else {
             $this->migrationPaths[] = $this->defaultMigrationPath;
             foreach (Yii::$app->modules as $name => $module) {
                 $this->migrationPaths[] = $this->getMigrationPath($name);
             }
         }
         $this->migrationPaths = array_unique($this->migrationPaths);
         for ($i = 0; $i < count($this->migrationPaths); $i++) {
             $this->migrationPaths[$i] = Yii::getAlias($this->migrationPaths[$i]);
             $this->stdout(' - ' . $this->migrationPaths[$i] . PHP_EOL);
         }
         $this->stdout(PHP_EOL);
         return true;
     } else {
         return false;
     }
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     echo "\n";
     if ($this->showBaseMigration) {
         $this->additionalPaths = ArrayHelper::merge([['name' => $this->baseMigrationName, 'path' => $this->migrationPath]], $this->additionalPaths);
     }
     $this->selectModule();
     return parent::beforeAction($action);
 }
Beispiel #3
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $this->initModuleMigrationDirectories();
         return true;
     } else {
         return false;
     }
 }
 public function beforeAction($action)
 {
     $path = \Yii::getAlias($this->migrationPlatformPath);
     if (!is_dir($path)) {
         throw new \Exception("The migration directory \"{$this->migrationPlatformPath}\" does not exist.");
     }
     $this->migrationPlatformPath = $path;
     return parent::beforeAction($action);
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     if ($action->id !== 'create' && is_object($this->db->schemaCache)) {
         $this->db->schemaCache->flush();
     }
     $this->allMigrationPaths['app'] = $this->migrationPath;
     $this->attachModuleMigrations();
     $this->setMigrationFiles();
     return true;
 }
 /**
  * Set `migrationNamespaces` if it empty
  * @param \yii\base\Action $action
  * @return bool
  * @throws Exception
  */
 public function beforeAction($action)
 {
     if (count($this->migrationNamespaces) === 0) {
         if ($this->moduleId) {
             $namespaces = $this->getMigrationNamespace(Yii::$app->getModule($this->moduleId));
             if (count($namespaces) === 0) {
                 throw new Exception('Can\'t find any one migration namespace');
             }
         } else {
             /** @var Module[] $modules */
             $modules = Yii::$app->getModules();
             $namespaces = ['app\\migrations'];
             foreach ($modules as $id => $module) {
                 $namespaces = array_merge($namespaces, $this->getMigrationNamespace(Yii::$app->getModule($id)));
             }
         }
         $this->migrationNamespaces = $namespaces;
     }
     return parent::beforeAction($action);
 }
Beispiel #7
0
 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * It checks the existence of the [[migrationPath]].
  * @param \yii\base\Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     $this->migrationPath = \Yii::getAlias($this->_runtimeMigrationPath);
     $this->_copyMigrations();
     return parent::beforeAction($action);
 }
Beispiel #8
0
 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * It blocks the standard Yii migration text from being outputted. It does so by only running the
  * parent implementation when the provided action id is not "info".
  */
 public function beforeAction($action)
 {
     if ($action->id === 'info') {
         return true;
     } else {
         return parent::beforeAction($action);
     }
 }