From 428d912811654ef57992af226c0be9167a81527c Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 13 Apr 2013 13:05:54 -0400 Subject: [PATCH] script WIP --- framework/base/Application.php | 27 ++++++++++++++++++++++++++- framework/base/ViewContent.php | 17 +++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/framework/base/Application.php b/framework/base/Application.php index 1dad257..1053210 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -87,7 +87,6 @@ class Application extends Module */ public $layout = 'main'; - private $_runtimePath; private $_ended = false; /** @@ -224,6 +223,8 @@ class Application extends Module return 0; } + private $_runtimePath; + /** * Returns the directory that stores runtime files. * @return string the directory that stores runtime files. Defaults to 'protected/runtime'. @@ -251,6 +252,30 @@ class Application extends Module } } + private $_vendorPath; + + /** + * Returns the directory that stores vendor files. + * @return string the directory that stores vendor files. Defaults to 'protected/vendor'. + */ + public function getVendorPath() + { + if ($this->_vendorPath !== null) { + $this->setVendorPath($this->getBasePath() . DIRECTORY_SEPARATOR . 'vendor'); + } + return $this->_vendorPath; + } + + /** + * Sets the directory that stores vendor files. + * @param string $path the directory that stores vendor files. + * @throws InvalidConfigException if the directory does not exist + */ + public function setVendorPath($path) + { + $this->_vendorPath = FileHelper::ensureDirectory($path); + } + /** * Returns the time zone used by this application. * This is a simple wrapper of PHP function date_default_timezone_get(). diff --git a/framework/base/ViewContent.php b/framework/base/ViewContent.php index 6a3b489..cf7684b 100644 --- a/framework/base/ViewContent.php +++ b/framework/base/ViewContent.php @@ -7,6 +7,8 @@ namespace yii\base; +use Yii; + /** * @author Qiang Xue * @since 2.0 @@ -43,7 +45,6 @@ class ViewContent extends Component * ~~~ */ public $bundles; - public $title; public $metaTags; public $linkTags; @@ -68,9 +69,21 @@ class ViewContent extends Component $this->jsFiles = null; } - public function registerBundle($name) + public function renderScripts($pos) { + } + public function registerBundle($name) + { + if (!isset($this->bundles[$name])) { + $am = Yii::$app->assets; + $bundle = $am->getBundle($name); + if ($bundle !== null) { + $this->bundles[$name] = $bundle; + } else { + throw new InvalidConfigException("Asset bundle does not exist: $name"); + } + } } public function getMetaTag($key)