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
97d291ca
Commit
97d291ca
authored
Feb 21, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `View::viewFile` and removed `ViewEvent::viewFile`
parent
d8d44b61
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
23 deletions
+16
-23
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
View.php
framework/base/View.php
+15
-8
ViewEvent.php
framework/base/ViewEvent.php
+0
-15
No files found.
framework/CHANGELOG.md
View file @
97d291ca
...
@@ -195,6 +195,7 @@ Yii Framework 2 Change Log
...
@@ -195,6 +195,7 @@ Yii Framework 2 Change Log
-
Renamed
`yii\web\User::idVar`
to
`idParam`
-
Renamed
`yii\web\User::idVar`
to
`idParam`
-
Renamed
`yii\web\User::authTimeoutVar`
to
`authTimeoutParam`
-
Renamed
`yii\web\User::authTimeoutVar`
to
`authTimeoutParam`
-
Renamed
`yii\web\User::returnUrlVar`
to
`returnUrlParam`
-
Renamed
`yii\web\User::returnUrlVar`
to
`returnUrlParam`
-
Chg: Added
`View::viewFile`
and removed
`ViewEvent::viewFile`
(qiangxue)
-
New #66:
[
Auth client library
](
https://github.com/yiisoft/yii2-authclient
)
OpenId, OAuth1, OAuth2 clients (klimov-paul)
-
New #66:
[
Auth client library
](
https://github.com/yiisoft/yii2-authclient
)
OpenId, OAuth1, OAuth2 clients (klimov-paul)
-
New #706: Added
`yii\widgets\Pjax`
and enhanced
`GridView`
to work with
`Pjax`
to support AJAX-update (qiangxue)
-
New #706: Added
`yii\widgets\Pjax`
and enhanced
`GridView`
to work with
`Pjax`
to support AJAX-update (qiangxue)
...
...
framework/base/View.php
View file @
97d291ca
...
@@ -92,6 +92,13 @@ class View extends Component
...
@@ -92,6 +92,13 @@ class View extends Component
* @internal
* @internal
*/
*/
public
$dynamicPlaceholders
=
[];
public
$dynamicPlaceholders
=
[];
/**
* @var string the path of the view file currently being rendered. If the view is not
* in the process of rendering a view, this property is null.
* This property is mainly provided for information purpose and is maintained by [[renderFile()]].
* Do not modify it.
*/
public
$viewFile
;
/**
/**
...
@@ -218,7 +225,8 @@ class View extends Component
...
@@ -218,7 +225,8 @@ class View extends Component
}
}
$output
=
''
;
$output
=
''
;
if
(
$this
->
beforeRender
(
$viewFile
))
{
$this
->
viewFile
=
$viewFile
;
if
(
$this
->
beforeRender
())
{
Yii
::
trace
(
"Rendering view file:
$viewFile
"
,
__METHOD__
);
Yii
::
trace
(
"Rendering view file:
$viewFile
"
,
__METHOD__
);
$ext
=
pathinfo
(
$viewFile
,
PATHINFO_EXTENSION
);
$ext
=
pathinfo
(
$viewFile
,
PATHINFO_EXTENSION
);
if
(
isset
(
$this
->
renderers
[
$ext
]))
{
if
(
isset
(
$this
->
renderers
[
$ext
]))
{
...
@@ -231,8 +239,9 @@ class View extends Component
...
@@ -231,8 +239,9 @@ class View extends Component
}
else
{
}
else
{
$output
=
$this
->
renderPhpFile
(
$viewFile
,
$params
);
$output
=
$this
->
renderPhpFile
(
$viewFile
,
$params
);
}
}
$this
->
afterRender
(
$
viewFile
,
$
output
);
$this
->
afterRender
(
$output
);
}
}
$this
->
viewFile
=
null
;
$this
->
context
=
$oldContext
;
$this
->
context
=
$oldContext
;
...
@@ -243,12 +252,11 @@ class View extends Component
...
@@ -243,12 +252,11 @@ class View extends Component
* This method is invoked right before [[renderFile()]] renders a view file.
* This method is invoked right before [[renderFile()]] renders a view file.
* The default implementation will trigger the [[EVENT_BEFORE_RENDER]] event.
* The default implementation will trigger the [[EVENT_BEFORE_RENDER]] event.
* If you override this method, make sure you call the parent implementation first.
* If you override this method, make sure you call the parent implementation first.
* @param string $viewFile the view file to be rendered
* @return boolean whether to continue rendering the view file.
* @return boolean whether to continue rendering the view file.
*/
*/
public
function
beforeRender
(
$viewFile
)
public
function
beforeRender
()
{
{
$event
=
new
ViewEvent
(
$viewFile
)
;
$event
=
new
ViewEvent
;
$this
->
trigger
(
self
::
EVENT_BEFORE_RENDER
,
$event
);
$this
->
trigger
(
self
::
EVENT_BEFORE_RENDER
,
$event
);
return
$event
->
isValid
;
return
$event
->
isValid
;
}
}
...
@@ -257,14 +265,13 @@ class View extends Component
...
@@ -257,14 +265,13 @@ class View extends Component
* This method is invoked right after [[renderFile()]] renders a view file.
* This method is invoked right after [[renderFile()]] renders a view file.
* The default implementation will trigger the [[EVENT_AFTER_RENDER]] event.
* The default implementation will trigger the [[EVENT_AFTER_RENDER]] event.
* If you override this method, make sure you call the parent implementation first.
* If you override this method, make sure you call the parent implementation first.
* @param string $viewFile the view file to be rendered
* @param string $output the rendering result of the view file. Updates to this parameter
* @param string $output the rendering result of the view file. Updates to this parameter
* will be passed back and returned by [[renderFile()]].
* will be passed back and returned by [[renderFile()]].
*/
*/
public
function
afterRender
(
$viewFile
,
&
$output
)
public
function
afterRender
(
&
$output
)
{
{
if
(
$this
->
hasEventHandlers
(
self
::
EVENT_AFTER_RENDER
))
{
if
(
$this
->
hasEventHandlers
(
self
::
EVENT_AFTER_RENDER
))
{
$event
=
new
ViewEvent
(
$viewFile
)
;
$event
=
new
ViewEvent
;
$event
->
output
=
$output
;
$event
->
output
=
$output
;
$this
->
trigger
(
self
::
EVENT_AFTER_RENDER
,
$event
);
$this
->
trigger
(
self
::
EVENT_AFTER_RENDER
,
$event
);
$output
=
$event
->
output
;
$output
=
$event
->
output
;
...
...
framework/base/ViewEvent.php
View file @
97d291ca
...
@@ -23,24 +23,9 @@ class ViewEvent extends Event
...
@@ -23,24 +23,9 @@ class ViewEvent extends Event
*/
*/
public
$output
;
public
$output
;
/**
/**
* @var string the view file path that is being rendered by [[View::renderFile()]].
*/
public
$viewFile
;
/**
* @var boolean whether to continue rendering the view file. Event handlers of
* @var boolean whether to continue rendering the view file. Event handlers of
* [[View::EVENT_BEFORE_RENDER]] may set this property to decide whether
* [[View::EVENT_BEFORE_RENDER]] may set this property to decide whether
* to continue rendering the current view file.
* to continue rendering the current view file.
*/
*/
public
$isValid
=
true
;
public
$isValid
=
true
;
/**
* Constructor.
* @param string $viewFile the view file path that is being rendered by [[View::renderFile()]].
* @param array $config name-value pairs that will be used to initialize the object properties
*/
public
function
__construct
(
$viewFile
,
$config
=
[])
{
$this
->
viewFile
=
$viewFile
;
parent
::
__construct
(
$config
);
}
}
}
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