public function actionConfig($filePath)
{
$filePath = Yii::getAlias($filePath);
if (file_exists($filePath)) {
if (!$this->confirm("File '{$filePath}' already exists. Do you wish to overwrite it?")) {
return self::EXIT_CODE_NORMAL;
}
}
$array = VarDumper::export($this->getOptionValues($this->action->id));
$content = <<<EOD
<?php
/**
* Configuration file for 'yii {$this->id}/{$this->defaultAction}' command.
*
* This file is automatically generated by 'yii {$this->id}/{$this->action->id}' command.
* It contains parameters for source code messages extraction.
* You may modify this file to suit your needs.
*
* You can use 'yii {$this->id}/{$this->action->id}-template' command to create
* template configuration file with detailed description for each parameter.
*/
return {$array};
EOD;
if (file_put_contents($filePath, $content) !== false) {
$this->stdout("Configuration file created: '{$filePath}'.\n\n", Console::FG_GREEN);
return self::EXIT_CODE_NORMAL;
} else {
$this->stdout("Configuration file was NOT created: '{$filePath}'.\n\n", Console::FG_RED);
return self::EXIT_CODE_ERROR;
}
}