Commit b836665d by Qiang Xue

Added beginPage and endPage events.

parent 6b770dad
...@@ -23,6 +23,14 @@ use yii\helpers\Html; ...@@ -23,6 +23,14 @@ use yii\helpers\Html;
class View extends Component class View extends Component
{ {
/** /**
* @event ViewEvent an event that is triggered by [[beginPage()]].
*/
const EVENT_BEGIN_PAGE = 'beginPage';
/**
* @event ViewEvent an event that is triggered by [[endPage()]].
*/
const EVENT_END_PAGE = 'endPage';
/**
* @event ViewEvent an event that is triggered by [[renderFile()]] right before it renders a view file. * @event ViewEvent an event that is triggered by [[renderFile()]] right before it renders a view file.
*/ */
const EVENT_BEFORE_RENDER = 'beforeRender'; const EVENT_BEFORE_RENDER = 'beforeRender';
...@@ -555,6 +563,8 @@ class View extends Component ...@@ -555,6 +563,8 @@ class View extends Component
{ {
ob_start(); ob_start();
ob_implicit_flush(false); ob_implicit_flush(false);
$this->trigger(self::EVENT_BEGIN_PAGE);
} }
/** /**
...@@ -562,6 +572,8 @@ class View extends Component ...@@ -562,6 +572,8 @@ class View extends Component
*/ */
public function endPage() public function endPage()
{ {
$this->trigger(self::EVENT_END_PAGE);
$content = ob_get_clean(); $content = ob_get_clean();
echo strtr($content, array( echo strtr($content, array(
self::PL_HEAD => $this->renderHeadHtml(), self::PL_HEAD => $this->renderHeadHtml(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment