示例#1
0
 public function beforeAction($action, $params)
 {
     $app = Yii::app();
     if (isset($app->migrateModules) && is_array($app->migrateModules)) {
         $this->_initModuleMigrationPaths($app->migrateModules);
     }
     return parent::beforeAction($action, $params);
 }
 /**
  * Verify our parameters have been passed before continuing, halt in case of errors.
  *
  * @param string $action
  * @param array $params
  * @return bool
  */
 public function beforeAction($action, $params)
 {
     if ($this->validHostingSwitch($this->hosting) === false || $this->validateDbCliArgs($action) === false) {
         return false;
     }
     $this->migrationTable = 'xlsws_migrations';
     return parent::beforeAction($action, $params);
 }
示例#3
0
 /**
  * prepare paths before any action
  *
  * @param $action
  * @param $params
  * @return bool
  */
 public function beforeAction($action, $params)
 {
     Yii::import($this->migrationPath . '.*');
     if ($return = parent::beforeAction($action, $params)) {
         echo "extended with EMigrateCommand by cebe <*****@*****.**>\n\n";
         if ($action == 'create' && !is_null($this->module)) {
             $this->usageError('create command can not be called with --module parameter!');
         }
         if (!is_null($this->module) && !is_string($this->module)) {
             $this->usageError('parameter --module must be a comma seperated list of modules or a single module name!');
         }
         // add a pseudo-module 'core'
         $this->modulePaths[$this->applicationModuleName] = $this->migrationPath;
         // remove disabled modules
         $disabledModules = array();
         foreach ($this->modulePaths as $module => $pathAlias) {
             if (in_array($module, $this->disabledModules)) {
                 unset($this->modulePaths[$module]);
                 $disabledModules[] = $module;
             }
         }
         if (!empty($disabledModules)) {
             echo "The following modules are disabled: " . implode(', ', $disabledModules) . "\n";
         }
         // only add modules that are desired by command
         $modules = false;
         if (!is_null($this->module)) {
             $modules = explode(',', $this->module);
             // error if specified module does not exist
             foreach ($modules as $module) {
                 if (!isset($this->modulePaths[$module])) {
                     die("\nError: module '{$module}' is not available!\n\n");
                 }
             }
             echo "Current call limited to module" . (count($modules) > 1 ? "s" : "") . ": " . implode(', ', $modules) . "\n";
         }
         echo "\n";
         // initialize modules
         foreach ($this->modulePaths as $module => $pathAlias) {
             if ($modules === false || in_array($module, $modules)) {
                 // nothing to do for application core module
                 if ($module == $this->applicationModuleName) {
                     continue;
                 }
                 $path = Yii::getPathOfAlias($pathAlias);
                 if ($path === false || !is_dir($path)) {
                     die('Error: The migration directory does not exist: ' . $pathAlias . "\n");
                 }
                 $this->modulePaths[$module] = $path;
                 Yii::import($pathAlias . '.*');
             } else {
                 unset($this->modulePaths[$module]);
             }
         }
     }
     return $return;
 }
示例#4
0
 /**
  * prepare paths before any action
  *
  * @param $action
  * @param $params
  * @return bool
  */
 public function beforeAction($action, $params)
 {
     $tmpMigrationPath = $this->migrationPath;
     $this->migrationPath = 'application';
     if (parent::beforeAction($action, $params)) {
         $this->migrationPath = $tmpMigrationPath;
         echo "extended with EMigrateCommand by cebe <*****@*****.**>\n\n";
         echo "Active database component (connectionString):\n    " . Yii::app()->{$this->connectionID}->connectionString . "\n\n";
         // check --module parameter
         if ($action == 'create' && !is_null($this->module)) {
             $this->usageError('create command can not be called with --module parameter!');
         }
         if (!is_null($this->module) && !is_string($this->module)) {
             $this->usageError('parameter --module must be a comma seperated list of modules or a single module name!');
         }
         // inform user about disabled modules
         if (!empty($this->disabledModules)) {
             echo "The following modules are disabled: " . implode(', ', $this->disabledModules) . "\n";
         }
         // only add modules that are desired by command
         $modules = false;
         if ($this->module !== null) {
             $modules = explode(',', $this->module);
             // error if specified module does not exist
             foreach ($modules as $module) {
                 if (in_array($module, $this->disabledModules)) {
                     echo "\nError: module '{$module}' is disabled!\n\n";
                     exit(1);
                 }
                 if (!isset($this->enabledModulePaths[$module])) {
                     echo "\nError: module '{$module}' is not available!\n\n";
                     exit(1);
                 }
             }
             echo "Current call is limited to module" . (count($modules) > 1 ? "s" : "") . ": " . implode(', ', $modules) . "\n";
         }
         echo "\n";
         // initialize modules
         foreach ($this->getEnabledModulePaths() as $module => $pathAlias) {
             if ($modules === false || in_array($module, $modules)) {
                 Yii::import($pathAlias . '.*');
                 $this->_runModulePaths[$module] = $pathAlias;
             }
         }
         return true;
     }
     return false;
 }
示例#5
0
 public function beforeAction($action, $params)
 {
     ob_start();
     return parent::beforeAction($action, $params);
 }