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
bfb9aa84
Commit
bfb9aa84
authored
Sep 14, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
11a4d6de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
GenerateController.php
extensions/gii/console/GenerateController.php
+19
-5
HelpController.php
framework/console/controllers/HelpController.php
+7
-3
No files found.
extensions/gii/console/GenerateController.php
View file @
bfb9aa84
...
@@ -45,7 +45,7 @@ class GenerateController extends Controller
...
@@ -45,7 +45,7 @@ class GenerateController extends Controller
public
function
__get
(
$name
)
public
function
__get
(
$name
)
{
{
return
isset
(
$this
->
_options
[
$name
])
?
$this
->
_options
[
$name
]
:
null
;
return
isset
(
$this
->
_options
[
$name
])
?
$this
->
_options
[
$name
]
:
null
;
// todo: should determine which options are valid
if
(
$this
->
action
)
{
if
(
$this
->
action
)
{
$options
=
$this
->
options
(
$this
->
action
->
id
);
$options
=
$this
->
options
(
$this
->
action
->
id
);
if
(
in_array
(
$name
,
$options
))
{
if
(
in_array
(
$name
,
$options
))
{
...
@@ -67,6 +67,7 @@ class GenerateController extends Controller
...
@@ -67,6 +67,7 @@ class GenerateController extends Controller
{
{
$this
->
_options
[
$name
]
=
$value
;
$this
->
_options
[
$name
]
=
$value
;
return
;
return
;
// todo: should determine which options are valid
if
(
$this
->
action
)
{
if
(
$this
->
action
)
{
$options
=
$this
->
options
(
$this
->
action
->
id
);
$options
=
$this
->
options
(
$this
->
action
->
id
);
if
(
in_array
(
$name
,
$options
))
{
if
(
in_array
(
$name
,
$options
))
{
...
@@ -122,9 +123,11 @@ class GenerateController extends Controller
...
@@ -122,9 +123,11 @@ class GenerateController extends Controller
public
function
options
(
$id
)
public
function
options
(
$id
)
{
{
if
(
isset
(
$this
->
generators
[
$id
]))
{
if
(
isset
(
$this
->
generators
[
$id
]))
{
$attributes
=
$this
->
generators
[
$id
]
->
attributes
;
unset
(
$attributes
[
'templates'
]);
return
array_merge
(
return
array_merge
(
parent
::
options
(
$id
),
parent
::
options
(
$id
),
array_keys
(
$
this
->
generators
[
$id
]
->
attributes
)
array_keys
(
$attributes
)
);
);
}
else
{
}
else
{
return
parent
::
options
(
$id
);
return
parent
::
options
(
$id
);
...
@@ -146,7 +149,8 @@ class GenerateController extends Controller
...
@@ -146,7 +149,8 @@ class GenerateController extends Controller
public
function
getActionHelp
(
$action
)
public
function
getActionHelp
(
$action
)
{
{
/** @var $action Action */
/** @var $action Action */
return
$action
->
generator
->
getDescription
();
$description
=
$action
->
generator
->
getDescription
();
return
wordwrap
(
preg_replace
(
'/\s+/'
,
' '
,
$description
));
}
}
/**
/**
...
@@ -164,17 +168,27 @@ class GenerateController extends Controller
...
@@ -164,17 +168,27 @@ class GenerateController extends Controller
{
{
/** @var $action Action */
/** @var $action Action */
$attributes
=
$action
->
generator
->
attributes
;
$attributes
=
$action
->
generator
->
attributes
;
unset
(
$attributes
[
'templates'
]);
$hints
=
$action
->
generator
->
hints
();
$hints
=
$action
->
generator
->
hints
();
$options
=
[];
$options
=
[];
foreach
(
$attributes
as
$name
=>
$value
)
{
foreach
(
$attributes
as
$name
=>
$value
)
{
$type
=
gettype
(
$value
);
$options
[
$name
]
=
[
$options
[
$name
]
=
[
'type'
=>
'string'
,
'type'
=>
$type
===
'NULL'
?
'string'
:
$type
,
'required'
=>
$action
->
generator
->
isAttributeRequired
(
$name
),
'default'
=>
$value
,
'default'
=>
$value
,
'comment'
=>
isset
(
$hints
[
$name
])
?
$
hints
[
$name
]
:
''
,
'comment'
=>
isset
(
$hints
[
$name
])
?
$
this
->
formatHint
(
$hints
[
$name
])
:
''
,
];
];
}
}
return
$options
;
return
$options
;
}
}
protected
function
formatHint
(
$hint
)
{
$hint
=
preg_replace
(
'%<code>(.*?)</code>%'
,
'\1'
,
$hint
);
$hint
=
preg_replace
(
'/\s+/'
,
' '
,
$hint
);
return
wordwrap
(
$hint
);
}
}
}
framework/console/controllers/HelpController.php
View file @
bfb9aa84
...
@@ -9,7 +9,6 @@ namespace yii\console\controllers;
...
@@ -9,7 +9,6 @@ namespace yii\console\controllers;
use
Yii
;
use
Yii
;
use
yii\base\Application
;
use
yii\base\Application
;
use
yii\base\InlineAction
;
use
yii\console\Controller
;
use
yii\console\Controller
;
use
yii\console\Exception
;
use
yii\console\Exception
;
use
yii\helpers\Console
;
use
yii\helpers\Console
;
...
@@ -302,7 +301,7 @@ class HelpController extends Controller
...
@@ -302,7 +301,7 @@ class HelpController extends Controller
if
(
!
empty
(
$options
))
{
if
(
!
empty
(
$options
))
{
$this
->
stdout
(
"
\n
OPTIONS
\n\n
"
,
Console
::
BOLD
);
$this
->
stdout
(
"
\n
OPTIONS
\n\n
"
,
Console
::
BOLD
);
foreach
(
$options
as
$name
=>
$option
)
{
foreach
(
$options
as
$name
=>
$option
)
{
echo
$this
->
formatOptionHelp
(
$this
->
ansiFormat
(
'--'
.
$name
,
Console
::
FG_RED
),
false
,
$option
[
'type'
],
$option
[
'default'
],
$option
[
'comment'
])
.
"
\n\n
"
;
echo
$this
->
formatOptionHelp
(
$this
->
ansiFormat
(
'--'
.
$name
,
Console
::
FG_RED
),
!
empty
(
$option
[
'required'
])
,
$option
[
'type'
],
$option
[
'default'
],
$option
[
'comment'
])
.
"
\n\n
"
;
}
}
}
}
}
}
...
@@ -329,7 +328,12 @@ class HelpController extends Controller
...
@@ -329,7 +328,12 @@ class HelpController extends Controller
// show as integer to avoid confusion
// show as integer to avoid confusion
$defaultValue
=
(
int
)
$defaultValue
;
$defaultValue
=
(
int
)
$defaultValue
;
}
}
$doc
=
"
$type
(defaults to "
.
var_export
(
$defaultValue
,
true
)
.
")"
;
if
(
is_string
(
$defaultValue
))
{
$defaultValue
=
"'"
.
$defaultValue
.
"'"
;
}
else
{
$defaultValue
=
var_export
(
$defaultValue
,
true
);
}
$doc
=
"
$type
(defaults to "
.
$defaultValue
.
")"
;
}
elseif
(
trim
(
$type
)
!==
''
)
{
}
elseif
(
trim
(
$type
)
!==
''
)
{
$doc
=
$type
;
$doc
=
$type
;
}
}
...
...
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