Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
38dcae3d
Commit
38dcae3d
authored
May 12, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished help ccommand.
parent
12932f0d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
7 deletions
+22
-7
YiiBase.php
framework/YiiBase.php
+5
-3
Controller.php
framework/console/Controller.php
+16
-3
HelpController.php
framework/console/commands/HelpController.php
+0
-0
ReflectionHelper.php
framework/util/ReflectionHelper.php
+1
-1
No files found.
framework/YiiBase.php
View file @
38dcae3d
...
...
@@ -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
::
$app
lication
->
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
::
$app
lication
->
getLocale
(
$language
)
->
getPluralRules
();
if
(
$n
=
min
(
count
(
$chunks
),
count
(
$expressions
)))
{
for
(
$i
=
0
;
$i
<
$n
;
$i
++
)
...
...
framework/console/Controller.php
View file @
38dcae3d
...
...
@@ -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
framework/console/commands/HelpController.php
View file @
38dcae3d
This diff is collapsed.
Click to expand it.
framework/util/ReflectionHelper.php
View file @
38dcae3d
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment