Commit 38dcae3d by Qiang Xue

Finished help ccommand.

parent 12932f0d
......@@ -531,11 +531,13 @@ class YiiBase
*/
public static function t($category, $message, $params = array(), $source = null, $language = null)
{
if (self::$app !== null)
// todo;
return $params !== array() ? strtr($message, $params) : $message;
if (self::$application !== null)
{
if ($source === null)
$source = $category === 'yii' ? 'coreMessages' : 'messages';
if (($source = self::$app->getComponent($source)) !== null)
if (($source = self::$application->getComponent($source)) !== null)
$message = $source->translate($category, $message, $language);
}
if ($params === array())
......@@ -549,7 +551,7 @@ class YiiBase
if (strpos($message, '#') === false)
{
$chunks = explode('|', $message);
$expressions = self::$app->getLocale($language)->getPluralRules();
$expressions = self::$application->getLocale($language)->getPluralRules();
if ($n = min(count($chunks), count($expressions)))
{
for ($i = 0;$i < $n;$i++)
......
......@@ -29,12 +29,23 @@ use yii\base\Exception;
class Controller extends \yii\base\Controller
{
/**
* This method is invoked when the request parameters do not satisfy the requirement of the specified action.
* The default implementation will throw an exception.
* @param Action $action the action being executed
* @param Exception $exception the exception about the invalid parameters
*/
public function invalidActionParams($action, $exception)
{
echo "Error: " . $exception->getMessage() . "\n";
\Yii::$application->end(1);
}
/**
* This method is invoked when extra parameters are provided to an action when it is executed.
* The default implementation does nothing.
* @param Action $action the action being executed
* @param array $expected the expected action parameters (name => value)
* @param array $actual the actual action parameters (name => value)
* @throws Exception if any unrecognized parameters are provided
*/
public function extraActionParams($action, $expected, $actual)
{
......@@ -42,9 +53,10 @@ class Controller extends \yii\base\Controller
$keys = array_diff(array_keys($actual), array_keys($expected));
if (!empty($keys)) {
throw new Exception(\Yii::t('yii', 'Unknown parameters: {params}', array(
echo "Error: " . \Yii::t('yii', 'Unknown parameters: {params}', array(
'{params}' => implode(', ', $keys),
)));
)) . "\n";
\Yii::$application->end(1);
}
}
}
\ No newline at end of file
......@@ -54,7 +54,7 @@ class ReflectionHelper
} elseif ($param->isDefaultValueAvailable()) {
$ps[$name] = $param->getDefaultValue();
} else {
throw new Exception(\Yii::t('yii', 'Missing required parameter "{name}".', array('{name' => $name)));
throw new Exception(\Yii::t('yii', 'Missing required parameter "{name}".', array('{name}' => $name)));
}
}
return $ps;
......
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