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
dbecf848
Commit
dbecf848
authored
Nov 08, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1156: action parameter binding now checks for array type.
parent
abb34936
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
Controller.php
framework/yii/web/Controller.php
+10
-2
No files found.
framework/yii/web/Controller.php
View file @
dbecf848
...
...
@@ -41,7 +41,7 @@ class Controller extends \yii\base\Controller
* @param \yii\base\Action $action the action to be bound with parameters
* @param array $params the parameters to be bound to the action
* @return array the valid parameters that the action can run with.
* @throws HttpException if there are missing parameters.
* @throws HttpException if there are missing
or invalid
parameters.
*/
public
function
bindActionParams
(
$action
,
$params
)
{
...
...
@@ -57,7 +57,15 @@ class Controller extends \yii\base\Controller
foreach
(
$method
->
getParameters
()
as
$param
)
{
$name
=
$param
->
getName
();
if
(
array_key_exists
(
$name
,
$params
))
{
$args
[]
=
$actionParams
[
$name
]
=
$params
[
$name
];
if
(
$param
->
isArray
())
{
$args
[]
=
$actionParams
[
$name
]
=
is_array
(
$params
[
$name
])
?
$params
[
$name
]
:
[
$params
[
$name
]];
}
elseif
(
!
is_array
(
$params
[
$name
]))
{
$args
[]
=
$actionParams
[
$name
]
=
$params
[
$name
];
}
else
{
throw
new
HttpException
(
400
,
Yii
::
t
(
'yii'
,
'Invalid data received for parameter "{param}".'
,
[
'param'
=>
$name
,
]));
}
unset
(
$params
[
$name
]);
}
elseif
(
$param
->
isDefaultValueAvailable
())
{
$args
[]
=
$actionParams
[
$name
]
=
$param
->
getDefaultValue
();
...
...
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