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
769c1dee
Commit
769c1dee
authored
May 12, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
be8dd940
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
6 deletions
+44
-6
Action.php
framework/base/Action.php
+5
-2
Controller.php
framework/base/Controller.php
+11
-0
InlineAction.php
framework/base/InlineAction.php
+5
-2
Controller.php
framework/console/Controller.php
+23
-2
No files found.
framework/base/Action.php
View file @
769c1dee
...
@@ -55,11 +55,14 @@ class Action extends Component
...
@@ -55,11 +55,14 @@ class Action extends Component
public
function
runWithParams
(
$params
)
public
function
runWithParams
(
$params
)
{
{
try
{
try
{
$params
=
ReflectionHelper
::
extractMethodParams
(
$this
,
'run'
,
$params
);
$ps
=
ReflectionHelper
::
extractMethodParams
(
$this
,
'run'
,
$params
);
return
(
int
)
call_user_func_array
(
array
(
$this
,
'run'
),
$params
);
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
$this
->
controller
->
invalidActionParams
(
$this
,
$e
);
$this
->
controller
->
invalidActionParams
(
$this
,
$e
);
return
1
;
return
1
;
}
}
if
(
$params
!==
$ps
)
{
$this
->
controller
->
extraActionParams
(
$this
,
$ps
,
$params
);
}
return
(
int
)
call_user_func_array
(
array
(
$this
,
'run'
),
$ps
);
}
}
}
}
framework/base/Controller.php
View file @
769c1dee
...
@@ -175,6 +175,17 @@ class Controller extends Component implements Initable
...
@@ -175,6 +175,17 @@ class Controller extends Component implements Initable
}
}
/**
/**
* This method is invoked when extra parameters are provided to an action when it is executed.
* The default implementation does nothing.
* @param Action $action the action being executed
* @param array $expected the expected action parameters (name => value)
* @param array $actual the actual action parameters (name => value)
*/
public
function
extraActionParams
(
$action
,
$expected
,
$actual
)
{
}
/**
* Handles the request whose action is not recognized.
* Handles the request whose action is not recognized.
* This method is invoked when the controller cannot find the requested action.
* This method is invoked when the controller cannot find the requested action.
* The default implementation simply throws an exception.
* The default implementation simply throws an exception.
...
...
framework/base/InlineAction.php
View file @
769c1dee
...
@@ -32,11 +32,14 @@ class InlineAction extends Action
...
@@ -32,11 +32,14 @@ class InlineAction extends Action
{
{
try
{
try
{
$method
=
'action'
.
$this
->
id
;
$method
=
'action'
.
$this
->
id
;
$params
=
ReflectionHelper
::
extractMethodParams
(
$this
->
controller
,
$method
,
$params
);
$ps
=
ReflectionHelper
::
extractMethodParams
(
$this
->
controller
,
$method
,
$params
);
return
(
int
)
call_user_func_array
(
array
(
$this
->
controller
,
$method
),
$params
);
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
$this
->
controller
->
invalidActionParams
(
$this
,
$e
);
$this
->
controller
->
invalidActionParams
(
$this
,
$e
);
return
1
;
return
1
;
}
}
if
(
$params
!==
$ps
)
{
$this
->
controller
->
extraActionParams
(
$this
,
$ps
,
$params
);
}
return
(
int
)
call_user_func_array
(
array
(
$this
->
controller
,
$method
),
$ps
);
}
}
}
}
framework/console/Controller.php
View file @
769c1dee
...
@@ -9,9 +9,8 @@
...
@@ -9,9 +9,8 @@
namespace
yii\console
;
namespace
yii\console
;
use
yii\base\
Inline
Action
;
use
yii\base\Action
;
use
yii\base\Exception
;
use
yii\base\Exception
;
use
yii\util\ReflectionHelper
;
/**
/**
* Command represents an executable console command.
* Command represents an executable console command.
...
@@ -51,6 +50,28 @@ use yii\util\ReflectionHelper;
...
@@ -51,6 +50,28 @@ use yii\util\ReflectionHelper;
class
Controller
extends
\yii\base\Controller
class
Controller
extends
\yii\base\Controller
{
{
/**
/**
* This method is invoked when the request parameters do not satisfy the requirement of the specified action.
* The default implementation will throw an exception.
* @param Action $action the action being executed
* @param Exception $exception the exception about the invalid parameters
* @throws Exception whenever this method is invoked
*/
public
function
invalidActionParams
(
$action
,
$exception
)
{
}
/**
* This method is invoked when extra parameters are provided to an action when it is executed.
* The default implementation does nothing.
* @param Action $action the action being executed
* @param array $expected the expected action parameters (name => value)
* @param array $actual the actual action parameters (name => value)
*/
public
function
extraActionParams
(
$action
,
$expected
,
$actual
)
{
}
/**
* Provides the command description.
* Provides the command description.
* This method may be overridden to return the actual command description.
* This method may be overridden to return the actual command description.
* @return string the command description. Defaults to 'Usage: php entry-script.php command-name'.
* @return string the command description. Defaults to 'Usage: php entry-script.php command-name'.
...
...
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