Commit fb4b0ae9 by Qiang Xue

The scripts in asset bundles are now registered in `View` at the end of…

The scripts in asset bundles are now registered in `View` at the end of `endBody()`. It was done in `endPage()` previously
parent 73dff014
...@@ -162,6 +162,7 @@ Yii Framework 2 Change Log ...@@ -162,6 +162,7 @@ Yii Framework 2 Change Log
- Chg: Renamed `yii\web\Request::acceptedLanguages` to `acceptableLanguages` (qiangxue) - Chg: Renamed `yii\web\Request::acceptedLanguages` to `acceptableLanguages` (qiangxue)
- Chg: Removed implementation of `Arrayable` from `yii\Object` (qiangxue) - Chg: Removed implementation of `Arrayable` from `yii\Object` (qiangxue)
- Chg: Renamed `ActiveRecordInterface::createActiveRelation()` to `createRelation()` (qiangxue) - Chg: Renamed `ActiveRecordInterface::createActiveRelation()` to `createRelation()` (qiangxue)
- Chg: The scripts in asset bundles are now registered in `View` at the end of `endBody()`. It was done in `endPage()` previously (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)
- New #1393: [Codeception testing framework integration](https://github.com/yiisoft/yii2-codeception) (Ragazzo) - New #1393: [Codeception testing framework integration](https://github.com/yiisoft/yii2-codeception) (Ragazzo)
......
...@@ -127,6 +127,58 @@ class View extends \yii\base\View ...@@ -127,6 +127,58 @@ class View extends \yii\base\View
private $_assetManager; private $_assetManager;
/**
* Marks the position of an HTML head section.
*/
public function head()
{
echo self::PH_HEAD;
}
/**
* Marks the beginning of an HTML body section.
*/
public function beginBody()
{
echo self::PH_BODY_BEGIN;
$this->trigger(self::EVENT_BEGIN_BODY);
}
/**
* Marks the ending of an HTML body section.
*/
public function endBody()
{
$this->trigger(self::EVENT_END_BODY);
echo self::PH_BODY_END;
foreach (array_keys($this->assetBundles) as $bundle) {
$this->registerAssetFiles($bundle);
}
}
/**
* Marks the ending of an HTML page.
* @param boolean $ajaxMode whether the view is rendering in AJAX mode.
* If true, the JS scripts registered at [[POS_READY]] and [[POS_LOAD]] positions
* will be rendered at the end of the view like normal scripts.
*/
public function endPage($ajaxMode = false)
{
$this->trigger(self::EVENT_END_PAGE);
$content = ob_get_clean();
echo strtr($content, [
self::PH_HEAD => $this->renderHeadHtml(),
self::PH_BODY_BEGIN => $this->renderBodyBeginHtml(),
self::PH_BODY_END => $this->renderBodyEndHtml($ajaxMode),
]);
$this->clear();
}
/** /**
* Renders a view in response to an AJAX request. * Renders a view in response to an AJAX request.
* *
...@@ -178,29 +230,6 @@ class View extends \yii\base\View ...@@ -178,29 +230,6 @@ class View extends \yii\base\View
} }
/** /**
* Marks the ending of an HTML page.
* @param boolean $ajaxMode whether the view is rendering in AJAX mode.
* If true, the JS scripts registered at [[POS_READY]] and [[POS_LOAD]] positions
* will be rendered at the end of the view like normal scripts.
*/
public function endPage($ajaxMode = false)
{
$this->trigger(self::EVENT_END_PAGE);
$content = ob_get_clean();
foreach (array_keys($this->assetBundles) as $bundle) {
$this->registerAssetFiles($bundle);
}
echo strtr($content, [
self::PH_HEAD => $this->renderHeadHtml(),
self::PH_BODY_BEGIN => $this->renderBodyBeginHtml(),
self::PH_BODY_END => $this->renderBodyEndHtml($ajaxMode),
]);
$this->clear();
}
/**
* Clears up the registered meta tags, link tags, css/js scripts and files. * Clears up the registered meta tags, link tags, css/js scripts and files.
*/ */
public function clear() public function clear()
...@@ -234,32 +263,6 @@ class View extends \yii\base\View ...@@ -234,32 +263,6 @@ class View extends \yii\base\View
} }
/** /**
* Marks the beginning of an HTML body section.
*/
public function beginBody()
{
echo self::PH_BODY_BEGIN;
$this->trigger(self::EVENT_BEGIN_BODY);
}
/**
* Marks the ending of an HTML body section.
*/
public function endBody()
{
$this->trigger(self::EVENT_END_BODY);
echo self::PH_BODY_END;
}
/**
* Marks the position of an HTML head section.
*/
public function head()
{
echo self::PH_HEAD;
}
/**
* Registers the named asset bundle. * Registers the named asset bundle.
* All dependent asset bundles will be registered. * All dependent asset bundles will be registered.
* @param string $name the name of the asset bundle. * @param string $name the name of the asset bundle.
......
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