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
af4455eb
Commit
af4455eb
authored
Feb 03, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished console support.
Finished migrate command.
parent
6a595de4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
6 deletions
+75
-6
Controller.php
framework/base/Controller.php
+5
-0
Request.php
framework/console/Request.php
+1
-1
HelpController.php
framework/console/controllers/HelpController.php
+46
-5
MigrateController.php
framework/console/controllers/MigrateController.php
+0
-0
migration.php
framework/views/migration.php
+23
-0
No files found.
framework/base/Controller.php
View file @
af4455eb
...
...
@@ -317,6 +317,11 @@ class Controller extends Component
return
$this
->
createView
()
->
renderPartial
(
$view
,
$params
);
}
public
function
renderFile
(
$file
,
$params
=
array
())
{
return
$this
->
createView
()
->
renderFile
(
$file
,
$params
);
}
public
function
createView
()
{
return
new
View
(
$this
);
...
...
framework/console/Request.php
View file @
af4455eb
...
...
@@ -15,7 +15,7 @@ namespace yii\console;
*/
class
Request
extends
\yii\base\Request
{
const
ANONYMOUS_PARAMS
=
'args'
;
const
ANONYMOUS_PARAMS
=
'
-
args'
;
/**
* @var string the controller route specified by this request. If this is an empty string,
...
...
framework/console/controllers/HelpController.php
View file @
af4455eb
...
...
@@ -179,17 +179,59 @@ class HelpController extends Controller
$prefix
=
$controller
->
getUniqueId
();
foreach
(
$actions
as
$action
)
{
if
(
$action
===
$controller
->
defaultAction
)
{
echo
"*
$prefix
/
$action
(default)
\n
"
;
echo
"*
$prefix
/
$action
(default)"
;
}
else
{
echo
"*
$prefix
/
$action
\n
"
;
echo
"*
$prefix
/
$action
"
;
}
$summary
=
$this
->
getActionSummary
(
$controller
,
$action
);
if
(
$summary
!==
''
)
{
echo
': '
.
$summary
;
}
echo
"
\n\n
To see the help of each sub-command, enter:
\n
"
;
echo
"
\n
"
;
}
echo
"
\n\n
To see the detailed information about individual sub-commands, enter:
\n
"
;
echo
"
\n
yiic help <sub-command>
\n\n
"
;
}
}
/**
* Returns the short summary of the action.
* @param Controller $controller the controller instance
* @param string $actionID action ID
* @return string the summary about the action
*/
protected
function
getActionSummary
(
$controller
,
$actionID
)
{
$action
=
$controller
->
createAction
(
$actionID
);
if
(
$action
===
null
)
{
return
''
;
}
if
(
$action
instanceof
InlineAction
)
{
$reflection
=
new
\ReflectionMethod
(
$controller
,
$action
->
actionMethod
);
}
else
{
$reflection
=
new
\ReflectionClass
(
$action
);
}
$tags
=
$this
->
parseComment
(
$reflection
->
getDocComment
());
if
(
$tags
[
'description'
]
!==
''
)
{
$limit
=
73
-
strlen
(
$action
->
getUniqueId
());
if
(
$actionID
===
$controller
->
defaultAction
)
{
$limit
-=
10
;
}
if
(
$limit
<
0
)
{
$limit
=
50
;
}
$description
=
$tags
[
'description'
];
if
((
$pos
=
strpos
(
$tags
[
'description'
],
"
\n
"
))
!==
false
)
{
$description
=
substr
(
$description
,
0
,
$pos
);
}
$text
=
substr
(
$description
,
0
,
$limit
);
return
strlen
(
$description
)
>
$limit
?
$text
.
'...'
:
$text
;
}
else
{
return
''
;
}
}
/**
* Displays the detailed information of a command action.
* @param Controller $controller the controller instance
* @param string $actionID action ID
...
...
@@ -200,7 +242,7 @@ class HelpController extends Controller
$action
=
$controller
->
createAction
(
$actionID
);
if
(
$action
===
null
)
{
throw
new
Exception
(
Yii
::
t
(
'yii'
,
'No help for unknown sub-command "{command}".'
,
array
(
'{command}'
=>
$action
->
getUniqueId
(
),
'{command}'
=>
rtrim
(
$controller
->
getUniqueId
()
.
'/'
.
$actionID
,
'/'
),
)));
}
if
(
$action
instanceof
InlineAction
)
{
...
...
@@ -232,7 +274,6 @@ class HelpController extends Controller
echo
"
\n\n
"
;
if
(
!
empty
(
$required
)
||
!
empty
(
$optional
))
{
echo
"
\n
ARGUMENTS
\n\n
"
;
echo
implode
(
"
\n\n
"
,
array_merge
(
$required
,
$optional
))
.
"
\n\n
"
;
}
...
...
framework/console/controllers/MigrateController.php
View file @
af4455eb
This diff is collapsed.
Click to expand it.
framework/views/migration.php
0 → 100644
View file @
af4455eb
<?php
/**
* This view is used by console/controllers/MigrateController.php
* The following variables are available in this view:
*
* @var string $className the new migration class name
*/
echo
"<?php
\n
"
;
?>
class
<?php
echo
$className
;
?>
extends \yii\db\Migration
{
public function up()
{
}
public function down()
{
echo "
<?php
echo
$className
;
?>
cannot be reverted.\n";
return false;
}
}
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