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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
87b49414
Commit
87b49414
authored
Feb 04, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed globalOptions array issue.
parent
ce2f58f0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
16 deletions
+8
-16
Controller.php
framework/console/Controller.php
+8
-16
No files found.
framework/console/Controller.php
View file @
87b49414
...
@@ -61,16 +61,21 @@ class Controller extends \yii\base\Controller
...
@@ -61,16 +61,21 @@ class Controller extends \yii\base\Controller
* @param array $params the parameters (name-value pairs) to be passed to the action.
* @param array $params the parameters (name-value pairs) to be passed to the action.
* @return integer the status of the action execution. 0 means normal, other values mean abnormal.
* @return integer the status of the action execution. 0 means normal, other values mean abnormal.
* @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully.
* @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully.
* @throws Exception if there are unknown options or missing arguments
* @see createAction
* @see createAction
*/
*/
public
function
runAction
(
$id
,
$params
=
[])
public
function
runAction
(
$id
,
$params
=
[])
{
{
if
(
!
empty
(
$params
))
{
if
(
!
empty
(
$params
))
{
// populate global options here so that they are available in beforeAction().
$options
=
$this
->
globalOptions
();
$options
=
$this
->
globalOptions
();
foreach
(
$params
as
$name
=>
$value
)
{
foreach
(
$params
as
$name
=>
$value
)
{
if
(
in_array
(
$name
,
$options
,
true
))
{
if
(
in_array
(
$name
,
$options
,
true
))
{
$this
->
$name
=
$value
;
$default
=
$this
->
$name
;
$this
->
$name
=
is_array
(
$default
)
?
preg_split
(
'/\s*,\s*/'
,
$value
)
:
$value
;
unset
(
$params
[
$name
]);
unset
(
$params
[
$name
]);
}
elseif
(
!
is_int
(
$name
))
{
throw
new
Exception
(
Yii
::
t
(
'yii'
,
'Unknown option: --{name}'
,
[
'name'
=>
$name
]));
}
}
}
}
}
}
...
@@ -89,27 +94,14 @@ class Controller extends \yii\base\Controller
...
@@ -89,27 +94,14 @@ class Controller extends \yii\base\Controller
*/
*/
public
function
bindActionParams
(
$action
,
$params
)
public
function
bindActionParams
(
$action
,
$params
)
{
{
$args
=
[];
if
(
!
empty
(
$params
))
{
$options
=
$this
->
globalOptions
();
foreach
(
$params
as
$name
=>
$value
)
{
if
(
in_array
(
$name
,
$options
,
true
))
{
$default
=
$this
->
$name
;
$this
->
$name
=
is_array
(
$default
)
?
preg_split
(
'/\s*,\s*/'
,
$value
)
:
$value
;
}
elseif
(
is_int
(
$name
))
{
$args
[]
=
$value
;
}
else
{
throw
new
Exception
(
Yii
::
t
(
'yii'
,
'Unknown option: --{name}'
,
[
'name'
=>
$name
]));
}
}
}
if
(
$action
instanceof
InlineAction
)
{
if
(
$action
instanceof
InlineAction
)
{
$method
=
new
\ReflectionMethod
(
$this
,
$action
->
actionMethod
);
$method
=
new
\ReflectionMethod
(
$this
,
$action
->
actionMethod
);
}
else
{
}
else
{
$method
=
new
\ReflectionMethod
(
$action
,
'run'
);
$method
=
new
\ReflectionMethod
(
$action
,
'run'
);
}
}
$args
=
array_values
(
$params
);
$missing
=
[];
$missing
=
[];
foreach
(
$method
->
getParameters
()
as
$i
=>
$param
)
{
foreach
(
$method
->
getParameters
()
as
$i
=>
$param
)
{
if
(
$param
->
isArray
()
&&
isset
(
$args
[
$i
]))
{
if
(
$param
->
isArray
()
&&
isset
(
$args
[
$i
]))
{
...
...
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