Browse Source

File creation checks at "AssetController" have been updated to use Exceptions.

tags/2.0.0-beta
Klimov Paul 12 years ago
parent
commit
6c179ef3a7
  1. 25
      framework/yii/console/controllers/AssetController.php

25
framework/yii/console/controllers/AssetController.php

@ -159,7 +159,7 @@ class AssetController extends Controller
}
}
$this->getAssetManager(); // check asset manager configuration
$this->getAssetManager(); // check asset manager configuration is correct
}
/**
@ -420,7 +420,7 @@ class AssetController extends Controller
}
$array = var_export($array, true);
$version = date('Y-m-d H:i:s', time());
$bytesWritten = file_put_contents($bundleFile, <<<EOD
$bundleFileContent = <<<EOD
<?php
/**
* This file is generated by the "yii script" command.
@ -428,9 +428,8 @@ class AssetController extends Controller
* @version $version
*/
return $array;
EOD
);
if ($bytesWritten <= 0) {
EOD;
if (!file_put_contents($bundleFile, $bundleFileContent)) {
throw new Exception("Unable to write output bundle configuration at '{$bundleFile}'.");
}
echo "Output bundle configuration created at '{$bundleFile}'.\n";
@ -498,6 +497,7 @@ EOD
* Combines Java Script files into a single one.
* @param array $inputFiles source file names.
* @param string $outputFile output file name.
* @throws \yii\console\Exception on failure.
*/
public function combineJsFiles($inputFiles, $outputFile)
{
@ -507,13 +507,16 @@ EOD
. file_get_contents($file)
. "/*** END FILE: $file ***/\n";
}
file_put_contents($outputFile, $content);
if (!file_put_contents($outputFile, $content)) {
throw new Exception("Unable to write output Java Script file '{$outputFile}'.");
}
}
/**
* Combines CSS files into a single one.
* @param array $inputFiles source file names.
* @param string $outputFile output file name.
* @throws \yii\console\Exception on failure.
*/
public function combineCssFiles($inputFiles, $outputFile)
{
@ -523,7 +526,9 @@ EOD
. $this->adjustCssUrl(file_get_contents($file), dirname($file), dirname($outputFile))
. "/*** END FILE: $file ***/\n";
}
file_put_contents($outputFile, $content);
if (!file_put_contents($outputFile, $content)) {
throw new Exception("Unable to write output CSS file '{$outputFile}'.");
}
}
/**
@ -590,6 +595,7 @@ EOD
/**
* Creates template of configuration file for [[actionCompress]].
* @param string $configFile output file name.
* @throws \yii\console\Exception on failure.
*/
public function actionTemplate($configFile)
{
@ -622,9 +628,8 @@ EOD;
return;
}
}
$bytesWritten = file_put_contents($configFile, $template);
if ($bytesWritten<=0) {
echo "Error: unable to write file '{$configFile}'!\n\n";
if (!file_put_contents($configFile, $template)) {
throw new Exception("Unable to write template file '{$configFile}'.");
} else {
echo "Configuration file template created at '{$configFile}'.\n\n";
}

Loading…
Cancel
Save