Skip to content

Commit

Permalink
added another workaround to detect the application config
Browse files Browse the repository at this point in the history
  • Loading branch information
schmunk42 committed Jan 5, 2015
1 parent 91ce93e commit 3d9a405
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions commands/BatchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public function actionIndex()
'tablePrefix' => $this->tablePrefix,
'generateModelClass' => $this->extendedModels,
'modelClass' => isset($this->tableNameMap[$table]) ? $this->tableNameMap[$table] :
Inflector::camelize($table), // TODO: setting is not recognized in giiant
Inflector::camelize($table), // TODO: setting is not recognized in giiant
'baseClass' => $this->modelBaseClass,
'tableNameMap' => $this->tableNameMap
];
$route = 'gii/giiant-model';
$route = 'gii/giiant-model';

$app = \Yii::$app;
$temp = new \yii\console\Application($config);
Expand All @@ -115,7 +115,7 @@ public function actionIndex()
// create CRUDs
$providers = ArrayHelper::merge($this->crudProviders, Generator::getCoreProviders());
foreach ($this->tables AS $table) {
$table = str_replace($this->tablePrefix,'',$table);
$table = str_replace($this->tablePrefix, '', $table);
$name = isset($this->tableNameMap[$table]) ? $this->tableNameMap[$table] : Inflector::camelize($table);
$params = [
'interactive' => $this->interactive,
Expand All @@ -131,8 +131,8 @@ public function actionIndex()
'providerList' => implode(',', $providers),
];
$route = 'gii/giiant-crud';
$app = \Yii::$app;
$temp = new \yii\console\Application($config);
$app = \Yii::$app;
$temp = new \yii\console\Application($config);
$temp->runAction(ltrim($route, '/'), $params);
unset($temp);
\Yii::$app = $app;
Expand All @@ -145,16 +145,20 @@ public function actionIndex()
*/
protected function getYiiConfiguration()
{
$config = \yii\helpers\ArrayHelper::merge(
require(\Yii::getAlias('@app') . '/../common/config/main.php'),
(is_file(\Yii::getAlias('@app') . '/../common/config/main-local.php')) ?
require(\Yii::getAlias('@app') . '/../common/config/main-local.php')
: [],
require(\Yii::getAlias('@app') . '/../console/config/main.php'),
(is_file(\Yii::getAlias('@app') . '/../console/config/main-local.php')) ?
require(\Yii::getAlias('@app') . '/../console/config/main-local.php')
: []
);
if (isset($GLOBALS['config'])) {
$config = $GLOBALS['config'];
} else {
$config = \yii\helpers\ArrayHelper::merge(
require(\Yii::getAlias('@app') . '/../common/config/main.php'),
(is_file(\Yii::getAlias('@app') . '/../common/config/main-local.php')) ?
require(\Yii::getAlias('@app') . '/../common/config/main-local.php')
: [],
require(\Yii::getAlias('@app') . '/../console/config/main.php'),
(is_file(\Yii::getAlias('@app') . '/../console/config/main-local.php')) ?
require(\Yii::getAlias('@app') . '/../console/config/main-local.php')
: []
);
}
return $config;
}
}

0 comments on commit 3d9a405

Please sign in to comment.