Commit 50926122 by Klimov Paul

Method "console\controllers\AssetController::actionTemplate()" has been updated to be more verbose.

parent f4cb1e4a
...@@ -55,6 +55,7 @@ class AssetControllerTest extends TestCase ...@@ -55,6 +55,7 @@ class AssetControllerTest extends TestCase
{ {
$module = $this->getMock('yii\\base\\Module', array('fake'), array('console')); $module = $this->getMock('yii\\base\\Module', array('fake'), array('console'));
$assetController = new AssetController('asset', $module); $assetController = new AssetController('asset', $module);
$assetController->interactive = false;
$assetController->jsCompressor = 'cp {from} {to}'; $assetController->jsCompressor = 'cp {from} {to}';
$assetController->cssCompressor = 'cp {from} {to}'; $assetController->cssCompressor = 'cp {from} {to}';
return $assetController; return $assetController;
......
...@@ -322,6 +322,10 @@ EOD ...@@ -322,6 +322,10 @@ EOD
file_put_contents($tmpFile, $content); file_put_contents($tmpFile, $content);
} }
/**
* Creates template of configuration file for [[actionCompress]].
* @param string $configFile output file name.
*/
public function actionTemplate($configFile) public function actionTemplate($configFile)
{ {
$template = <<<EOD $template = <<<EOD
...@@ -348,6 +352,16 @@ return array( ...@@ -348,6 +352,16 @@ return array(
), ),
); );
EOD; EOD;
file_put_contents($configFile, $template); if (file_exists($configFile)) {
if (!$this->confirm("File '{$configFile}' already exists. Do you wish to overwrite it?")) {
return;
}
}
$bytesWritten = file_put_contents($configFile, $template);
if ($bytesWritten<=0) {
echo "Error: unable to write file '{$configFile}'!\n\n";
} else {
echo "Configuration file template created at '{$configFile}'.\n\n";
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment