From 3c9b157814f09bb1e35bc63fe8d9aa799afa76be Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Sun, 9 Jun 2013 15:11:34 +0300 Subject: [PATCH] Exception usage has been added to "yii\console\controllers\MessageController". --- .../yii/console/controllers/MessageController.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/framework/yii/console/controllers/MessageController.php b/framework/yii/console/controllers/MessageController.php index 44cf1b1..828f25f 100644 --- a/framework/yii/console/controllers/MessageController.php +++ b/framework/yii/console/controllers/MessageController.php @@ -9,6 +9,8 @@ namespace yii\console\controllers; use yii\console\Controller; +use yii\console\Exception; +use yii\helpers\FileHelper; /** * This command extracts messages to be translated from source files. @@ -26,6 +28,7 @@ class MessageController extends Controller * * @param string $config the path of the configuration file. You can find * an example in framework/messages/config.php. + * @throws \yii\console\Exception on failure. * * The file can be placed anywhere and must be a valid PHP script which * returns an array of name-value pairs. Each name-value pair represents @@ -58,25 +61,25 @@ class MessageController extends Controller public function actionIndex($config) { if (!is_file($config)) { - $this->usageError("the configuration file {$config} does not exist."); + throw new Exception("the configuration file {$config} does not exist."); } - $config = require_once($config); + $config = require($config); - $translator='Yii::t'; + $translator = 'Yii::t'; extract($config); if (!isset($sourcePath, $messagePath, $languages)) { - $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); + throw new Exception('The configuration file must specify "sourcePath", "messagePath" and "languages".'); } if (!is_dir($sourcePath)) { - $this->usageError("The source path $sourcePath is not a valid directory."); + throw new Exception("The source path {$sourcePath} is not a valid directory."); } if (!is_dir($messagePath)) { - $this->usageError("The message path $messagePath is not a valid directory."); + throw new Exception("The message path {$messagePath} is not a valid directory."); } if (empty($languages)) { - $this->usageError("Languages cannot be empty."); + throw new Exception("Languages cannot be empty."); } if (!isset($overwrite)) { @@ -96,7 +99,7 @@ class MessageController extends Controller if (isset($exclude)) { $options['exclude'] = $exclude; } - $files = CFileHelper::findFiles(realpath($sourcePath), $options); + $files = FileHelper::findFiles(realpath($sourcePath), $options); $messages = array(); foreach ($files as $file) { @@ -209,7 +212,7 @@ class MessageController extends Controller /** * Message translations. * - * This file is automatically generated by 'yii message' command. + * This file is automatically generated by 'yii {$this->id}' command. * It contains the localizable messages extracted from source code. * You may modify this file by translating the extracted messages. *