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
4402073d
Commit
4402073d
authored
Jan 31, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVC WIP
parent
311f876b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
38 deletions
+28
-38
View.php
framework/base/View.php
+10
-10
Controller.php
framework/console/Controller.php
+18
-28
No files found.
framework/base/View.php
View file @
4402073d
...
@@ -28,8 +28,8 @@ class View extends Component
...
@@ -28,8 +28,8 @@ class View extends Component
*/
*/
public
$owner
;
public
$owner
;
/**
/**
* @var string
|boolean
the layout to be applied when [[render()]] or [[renderContent()]] is called.
* @var string the layout to be applied when [[render()]] or [[renderContent()]] is called.
* If not set, it will use the
value of [[Application::layout]]. If false, no layout will be applied
.
* If not set, it will use the
[[Module::layout]] of the currently active module
.
*/
*/
public
$layout
;
public
$layout
;
/**
/**
...
@@ -393,7 +393,8 @@ class View extends Component
...
@@ -393,7 +393,8 @@ class View extends Component
* * If the controller's [[Controller::layout|layout]] is a string, use it as the layout name
* * If the controller's [[Controller::layout|layout]] is a string, use it as the layout name
* and search for the layout file under the layout path of the parent module of the controller;
* and search for the layout file under the layout path of the parent module of the controller;
* * If the controller's [[Controller::layout|layout]] is null, look through its ancestor modules
* * If the controller's [[Controller::layout|layout]] is null, look through its ancestor modules
* and find one whose [[Module::layout|layout]] is not null. Use the layout specified by that module;
* and find the first one whose [[Module::layout|layout]] is not null. Use the layout specified
* by that module;
* - Returns false for all other cases.
* - Returns false for all other cases.
*
*
* Like view names, a layout name can take several formats:
* Like view names, a layout name can take several formats:
...
@@ -425,7 +426,7 @@ class View extends Component
...
@@ -425,7 +426,7 @@ class View extends Component
$module
=
Yii
::
$application
;
$module
=
Yii
::
$application
;
}
}
$view
=
$this
->
layout
;
$view
=
$this
->
layout
;
}
elseif
(
$this
->
layout
===
null
&&
$this
->
owner
instanceof
Controller
)
{
}
elseif
(
$this
->
owner
instanceof
Controller
)
{
if
(
is_string
(
$this
->
owner
->
layout
))
{
if
(
is_string
(
$this
->
owner
->
layout
))
{
$module
=
$this
->
owner
->
module
;
$module
=
$this
->
owner
->
module
;
$view
=
$this
->
owner
->
layout
;
$view
=
$this
->
owner
->
layout
;
...
@@ -434,14 +435,13 @@ class View extends Component
...
@@ -434,14 +435,13 @@ class View extends Component
while
(
$module
!==
null
&&
$module
->
layout
===
null
)
{
while
(
$module
!==
null
&&
$module
->
layout
===
null
)
{
$module
=
$module
->
module
;
$module
=
$module
->
module
;
}
}
if
(
$module
===
null
||
!
is_string
(
$module
->
layout
))
{
if
(
$module
!==
null
&&
is_string
(
$module
->
layout
))
{
return
false
;
}
$view
=
$module
->
layout
;
$view
=
$module
->
layout
;
}
else
{
return
false
;
}
}
}
else
{
}
}
if
(
!
isset
(
$view
))
{
return
false
;
return
false
;
}
}
...
...
framework/console/Controller.php
View file @
4402073d
...
@@ -9,9 +9,10 @@
...
@@ -9,9 +9,10 @@
namespace
yii\console
;
namespace
yii\console
;
use
Yii
;
use
yii\base\Action
;
use
yii\base\Action
;
use
yii\base\InvalidRequestException
;
use
yii\base\InvalidRouteException
;
use
yii\base\InvalidRouteException
;
use
yii\base\Exception
;
/**
/**
* Controller is the base class of console command classes.
* Controller is the base class of console command classes.
...
@@ -57,35 +58,24 @@ class Controller extends \yii\base\Controller
...
@@ -57,35 +58,24 @@ class Controller extends \yii\base\Controller
}
}
/**
/**
* This method is invoked when the request parameters do not satisfy the requirement of the specified action.
* Validates the parameter being bound to actions.
* The default implementation will throw an exception.
* This method is invoked when parameters are being bound to the currently requested action.
* @param Action $action the action being executed
* Child classes may override this method to throw exceptions when there are missing and/or unknown parameters.
* @param Exception $exception the exception about the invalid parameters
* @param Action $action the currently requested action
* @param array $missingParams the names of the missing parameters
* @param array $unknownParams the unknown parameters (name=>value)
* @throws InvalidRequestException if there are missing or unknown parameters
*/
*/
public
function
invalidActionParams
(
$action
,
$exception
)
public
function
validateActionParams
(
$action
,
$missingParams
,
$unknownParams
)
{
{
echo
\Yii
::
t
(
'yii'
,
'Error: {message}'
,
array
(
if
(
!
empty
(
$missingParams
))
{
'{message}'
=>
$exception
->
getMessage
(),
throw
new
InvalidRequestException
(
Yii
::
t
(
'yii'
,
'Missing required options: {params}'
,
array
(
));
'{params}'
=>
implode
(
', '
,
$missingParams
),
\Yii
::
$application
->
end
(
1
);
)));
}
}
elseif
(
!
empty
(
$unknownParams
))
{
throw
new
InvalidRequestException
(
Yii
::
t
(
'yii'
,
'Unknown options: {params}'
,
array
(
/**
'{params}'
=>
implode
(
', '
,
$unknownParams
),
* This method is invoked when extra parameters are provided to an action while it is executed.
)));
* @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
)
{
unset
(
$expected
[
'args'
],
$actual
[
'args'
]);
$keys
=
array_diff
(
array_keys
(
$actual
),
array_keys
(
$expected
));
if
(
!
empty
(
$keys
))
{
echo
\Yii
::
t
(
'yii'
,
'Error: Unknown parameter(s): {params}'
,
array
(
'{params}'
=>
implode
(
', '
,
$keys
),
))
.
"
\n
"
;
\Yii
::
$application
->
end
(
1
);
}
}
}
}
...
...
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