schmunk42\giiant\commands\BatchController::beforeAction PHP Метод

beforeAction() публичный Метод

Loads application configuration and checks tables parameter.
public beforeAction ( Action $action ) : boolean
$action yii\base\Action
Результат boolean
    public function beforeAction($action)
    {
        $this->appConfig = $this->getYiiConfiguration();
        $this->appConfig['id'] = 'temp';
        $this->modelGenerator = new ModelGenerator(['db' => $this->modelDb]);
        if (!$this->tables) {
            $this->modelGenerator->tableName = '*';
            $this->tables = $this->modelGenerator->getTableNames();
            $tableList = implode("\n\t- ", $this->tables);
            $msg = "Are you sure that you want to run action \"{$action->id}\" for the following tables?\n\t- {$tableList}\n\n";
            if (!$this->confirm($msg)) {
                return false;
            }
        }
        return parent::beforeAction($action);
    }

Usage Example

Пример #1
0
 public function beforeAction($action)
 {
     \Yii::$app->controller->module = \Yii::$app->getModule('gii');
     return parent::beforeAction($action);
 }