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
277d8cba
Commit
277d8cba
authored
Sep 04, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Got rid of console inline action
parent
dbac35b1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
77 deletions
+11
-77
Controller.php
framework/base/Controller.php
+1
-13
Controller.php
framework/console/Controller.php
+3
-12
InlineAction.php
framework/console/InlineAction.php
+0
-46
HelpController.php
framework/console/controllers/HelpController.php
+7
-6
No files found.
framework/base/Controller.php
View file @
277d8cba
...
@@ -220,7 +220,7 @@ class Controller extends Component implements ViewContextInterface
...
@@ -220,7 +220,7 @@ class Controller extends Component implements ViewContextInterface
if
(
method_exists
(
$this
,
$methodName
))
{
if
(
method_exists
(
$this
,
$methodName
))
{
$method
=
new
\ReflectionMethod
(
$this
,
$methodName
);
$method
=
new
\ReflectionMethod
(
$this
,
$methodName
);
if
(
$method
->
isPublic
()
&&
$method
->
getName
()
===
$methodName
)
{
if
(
$method
->
isPublic
()
&&
$method
->
getName
()
===
$methodName
)
{
return
$this
->
createActionObject
(
$id
,
$methodName
);
return
new
InlineAction
(
$id
,
$this
,
$methodName
);
}
}
}
}
}
}
...
@@ -229,18 +229,6 @@ class Controller extends Component implements ViewContextInterface
...
@@ -229,18 +229,6 @@ class Controller extends Component implements ViewContextInterface
}
}
/**
/**
* Creates action object instance
*
* @param string $id the ID of this action
* @param string $methodName the controller method that action is associated with
* @return \yii\base\InlineAction
*/
protected
function
createActionObject
(
$id
,
$methodName
)
{
return
new
InlineAction
(
$id
,
$this
,
$methodName
);
}
/**
* This method is invoked right before an action is executed.
* This method is invoked right before an action is executed.
*
*
* The method will trigger the [[EVENT_BEFORE_ACTION]] event. The return value of the method
* The method will trigger the [[EVENT_BEFORE_ACTION]] event. The return value of the method
...
...
framework/console/Controller.php
View file @
277d8cba
...
@@ -60,15 +60,6 @@ class Controller extends \yii\base\Controller
...
@@ -60,15 +60,6 @@ class Controller extends \yii\base\Controller
}
}
/**
/**
* @inheritdoc
* @return \yii\console\InlineAction
*/
protected
function
createActionObject
(
$id
,
$methodName
)
{
return
new
InlineAction
(
$id
,
$this
,
$methodName
);
}
/**
* Runs an action with the specified action ID and parameters.
* Runs an action with the specified action ID and parameters.
* If the action ID is empty, the method will use [[defaultAction]].
* If the action ID is empty, the method will use [[defaultAction]].
* @param string $id the ID of the action to be executed.
* @param string $id the ID of the action to be executed.
...
@@ -108,7 +99,7 @@ class Controller extends \yii\base\Controller
...
@@ -108,7 +99,7 @@ class Controller extends \yii\base\Controller
*/
*/
public
function
bindActionParams
(
$action
,
$params
)
public
function
bindActionParams
(
$action
,
$params
)
{
{
if
(
$action
instanceof
InlineAction
)
{
if
(
$action
instanceof
\yii\base\
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'
);
...
@@ -303,7 +294,7 @@ class Controller extends \yii\base\Controller
...
@@ -303,7 +294,7 @@ class Controller extends \yii\base\Controller
$class
=
new
\ReflectionClass
(
$action
);
$class
=
new
\ReflectionClass
(
$action
);
}
}
if
(
$action
instanceof
InlineAction
)
{
if
(
$action
instanceof
\yii\base\
InlineAction
)
{
$class
=
new
\ReflectionMethod
(
$this
,
$action
->
actionMethod
);
$class
=
new
\ReflectionMethod
(
$this
,
$action
->
actionMethod
);
}
}
...
@@ -332,7 +323,7 @@ class Controller extends \yii\base\Controller
...
@@ -332,7 +323,7 @@ class Controller extends \yii\base\Controller
$class
=
new
\ReflectionClass
(
$this
->
createAction
(
$actionID
));
$class
=
new
\ReflectionClass
(
$this
->
createAction
(
$actionID
));
}
}
if
(
$action
instanceof
InlineAction
)
{
if
(
$action
instanceof
\yii\base\
InlineAction
)
{
$class
=
new
\ReflectionMethod
(
$this
,
$action
->
actionMethod
);
$class
=
new
\ReflectionMethod
(
$this
,
$action
->
actionMethod
);
}
}
...
...
framework/console/InlineAction.php
deleted
100644 → 0
View file @
dbac35b1
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\console
;
use
Yii
;
use
yii\helpers\Console
;
/**
* InlineAction represents an action that is defined as a controller method.
*
* @inheritdoc
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class
InlineAction
extends
\yii\base\InlineAction
{
/**
* Returns a short description (one line) of information about the action.
*
* The default implementation returns help information retrieved from the PHPDoc comments.
*
* @return string
*/
public
function
getDescription
()
{
return
null
;
}
/**
* Returns help information for the action.
*
* The default implementation returns help information retrieved from the PHPDoc comments.
* @return string
*/
public
function
getHelp
()
{
return
null
;
}
}
framework/console/controllers/HelpController.php
View file @
277d8cba
...
@@ -12,7 +12,6 @@ use yii\base\Application;
...
@@ -12,7 +12,6 @@ use yii\base\Application;
use
yii\console\Action
;
use
yii\console\Action
;
use
yii\console\Controller
;
use
yii\console\Controller
;
use
yii\console\Exception
;
use
yii\console\Exception
;
use
yii\console\InlineAction
;
use
yii\helpers\Console
;
use
yii\helpers\Console
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
...
@@ -250,14 +249,15 @@ class HelpController extends Controller
...
@@ -250,14 +249,15 @@ class HelpController extends Controller
*/
*/
protected
function
getActionSummary
(
$controller
,
$actionID
)
protected
function
getActionSummary
(
$controller
,
$actionID
)
{
{
$description
=
''
;
$description
=
null
;
$action
=
$controller
->
createAction
(
$actionID
);
$action
=
$controller
->
createAction
(
$actionID
);
if
(
$action
instanceof
InlineAction
||
$action
instanceof
Action
)
{
if
(
$action
instanceof
Action
)
{
$description
=
$action
->
getDescription
();
$description
=
$action
->
getDescription
();
}
if
(
$description
===
null
)
{
if
(
$description
===
null
)
{
$description
=
$controller
->
getDescription
(
$actionID
);
$description
=
$controller
->
getDescription
(
$actionID
);
}
}
}
return
$description
;
return
$description
;
}
}
...
@@ -275,16 +275,17 @@ class HelpController extends Controller
...
@@ -275,16 +275,17 @@ class HelpController extends Controller
'command'
=>
rtrim
(
$controller
->
getUniqueId
()
.
'/'
.
$actionID
,
'/'
),
'command'
=>
rtrim
(
$controller
->
getUniqueId
()
.
'/'
.
$actionID
,
'/'
),
]));
]));
}
}
if
(
$action
instanceof
InlineAction
)
{
$description
=
null
;
if
(
$action
instanceof
\yii\base\InlineAction
)
{
$method
=
new
\ReflectionMethod
(
$controller
,
$action
->
actionMethod
);
$method
=
new
\ReflectionMethod
(
$controller
,
$action
->
actionMethod
);
}
else
{
}
else
{
$description
=
$action
->
getHelp
();
$method
=
new
\ReflectionMethod
(
$action
,
'run'
);
$method
=
new
\ReflectionMethod
(
$action
,
'run'
);
}
}
$tags
=
$this
->
parseComment
(
$method
->
getDocComment
());
$tags
=
$this
->
parseComment
(
$method
->
getDocComment
());
$options
=
$this
->
getOptionHelps
(
$controller
,
$actionID
);
$options
=
$this
->
getOptionHelps
(
$controller
,
$actionID
);
$description
=
$action
->
getHelp
();
if
(
$description
===
null
)
{
if
(
$description
===
null
)
{
$description
=
$controller
->
getHelp
(
$actionID
);
$description
=
$controller
->
getHelp
(
$actionID
);
}
}
...
...
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