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
9779e9c9
Commit
9779e9c9
authored
Feb 04, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for using arrays as option values for console commands
parent
bb2256a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
1 deletion
+6
-1
console.md
docs/guide/console.md
+3
-0
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
Controller.php
framework/console/Controller.php
+2
-1
No files found.
docs/guide/console.md
View file @
9779e9c9
...
...
@@ -91,6 +91,9 @@ to a console command. The method should return a list of public property names o
When running a command, you may specify the value of an option using the syntax
`--OptionName=OptionValue`
.
This will assign
`OptionValue`
to the
`OptionName`
property of the controller class.
If the default value of an option is of array type, then if you set this option while running the command,
the option value will be converted into an array by splitting the input string by commas.
### Arguments
Besides options, a command can also receive arguments. The arguments will be passed as the parameters to the action
...
...
framework/CHANGELOG.md
View file @
9779e9c9
...
...
@@ -101,6 +101,7 @@ Yii Framework 2 Change Log
-
Enh #2132: Allow url of CSS and JS files registered in yii
\w
eb
\V
iew to be url alias (cebe)
-
Enh #2144:
`Html`
helper now supports rendering "data" attributes (qiangxue)
-
Enh #2156:
`yii migrate`
now automatically creates
`migrations`
directory if it does not exist (samdark)
-
Enh: Added support for using arrays as option values for console commands (qiangxue)
-
Enh: Added
`favicon.ico`
and
`robots.txt`
to default application templates (samdark)
-
Enh: Added
`Widget::autoIdPrefix`
to support prefixing automatically generated widget IDs (qiangxue)
-
Enh: Support for file aliases in console command 'message' (omnilight)
...
...
framework/console/Controller.php
View file @
9779e9c9
...
...
@@ -94,7 +94,8 @@ class Controller extends \yii\base\Controller
$options
=
$this
->
globalOptions
();
foreach
(
$params
as
$name
=>
$value
)
{
if
(
in_array
(
$name
,
$options
,
true
))
{
$this
->
$name
=
$value
;
$default
=
$this
->
$name
;
$this
->
$name
=
is_array
(
$default
)
?
preg_split
(
'/\s*,\s*/'
,
$value
)
:
$value
;
}
elseif
(
is_int
(
$name
))
{
$args
[]
=
$value
;
}
else
{
...
...
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