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
1fe7f5aa
Commit
1fe7f5aa
authored
Nov 27, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1335: findLayoutFile() should respect View::defaultExtension.
parent
af778d1a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
Controller.php
framework/yii/base/Controller.php
+12
-11
No files found.
framework/yii/base/Controller.php
View file @
1fe7f5aa
...
...
@@ -305,7 +305,7 @@ class Controller extends Component implements ViewContextInterface
public
function
render
(
$view
,
$params
=
[])
{
$output
=
$this
->
getView
()
->
render
(
$view
,
$params
,
$this
);
$layoutFile
=
$this
->
findLayoutFile
();
$layoutFile
=
$this
->
findLayoutFile
(
$this
->
getView
()
);
if
(
$layoutFile
!==
false
)
{
return
$this
->
getView
()
->
renderFile
(
$layoutFile
,
[
'content'
=>
$output
],
$this
);
}
else
{
...
...
@@ -386,38 +386,39 @@ class Controller extends Component implements ViewContextInterface
/**
* Finds the applicable layout file.
* @param View $view the view object to render the layout file
* @return string|boolean the layout file path, or false if layout is not needed.
* Please refer to [[render()]] on how to specify this parameter.
* @throws InvalidParamException if an invalid path alias is used to specify the layout
*/
protected
function
findLayoutFile
()
protected
function
findLayoutFile
(
$view
)
{
$module
=
$this
->
module
;
if
(
is_string
(
$this
->
layout
))
{
$
view
=
$this
->
layout
;
$
layout
=
$this
->
layout
;
}
elseif
(
$this
->
layout
===
null
)
{
while
(
$module
!==
null
&&
$module
->
layout
===
null
)
{
$module
=
$module
->
module
;
}
if
(
$module
!==
null
&&
is_string
(
$module
->
layout
))
{
$
view
=
$module
->
layout
;
$
layout
=
$module
->
layout
;
}
}
if
(
!
isset
(
$
view
))
{
if
(
!
isset
(
$
layout
))
{
return
false
;
}
if
(
strncmp
(
$
view
,
'@'
,
1
)
===
0
)
{
$file
=
Yii
::
getAlias
(
$
view
);
}
elseif
(
strncmp
(
$
view
,
'/'
,
1
)
===
0
)
{
$file
=
Yii
::
$app
->
getLayoutPath
()
.
DIRECTORY_SEPARATOR
.
$
view
;
if
(
strncmp
(
$
layout
,
'@'
,
1
)
===
0
)
{
$file
=
Yii
::
getAlias
(
$
layout
);
}
elseif
(
strncmp
(
$
layout
,
'/'
,
1
)
===
0
)
{
$file
=
Yii
::
$app
->
getLayoutPath
()
.
DIRECTORY_SEPARATOR
.
$
layout
;
}
else
{
$file
=
$module
->
getLayoutPath
()
.
DIRECTORY_SEPARATOR
.
$
view
;
$file
=
$module
->
getLayoutPath
()
.
DIRECTORY_SEPARATOR
.
$
layout
;
}
if
(
pathinfo
(
$file
,
PATHINFO_EXTENSION
)
===
''
)
{
$file
.=
'.php'
;
$file
.=
$view
->
defaultExtension
;
}
return
$file
;
}
...
...
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