From 955dc088b9c332d588cb57ad040b88a28b7b8b9a Mon Sep 17 00:00:00 2001 From: Max Lapko Date: Thu, 16 May 2013 10:34:15 +0300 Subject: [PATCH 1/2] Change magic methods to getters --- yii/debug/Toolbar.php | 5 +++-- yii/widgets/LinkPager.php | 2 +- yii/widgets/ListPager.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/yii/debug/Toolbar.php b/yii/debug/Toolbar.php index 591f0f6..c205277 100644 --- a/yii/debug/Toolbar.php +++ b/yii/debug/Toolbar.php @@ -26,8 +26,9 @@ class Toolbar extends Widget $url = Yii::$app->getUrlManager()->createUrl($this->debugAction, array( 'tag' => Yii::getLogger()->tag, )); - $this->view->registerJs("yii.debug.load('$id', '$url');"); - $this->view->registerAssetBundle('yii/debug'); + $view = $this->getView(); + $view->registerJs("yii.debug.load('$id', '$url');"); + $view->registerAssetBundle('yii/debug'); echo Html::tag('div', '', array( 'id' => $id, 'style' => 'display: none', diff --git a/yii/widgets/LinkPager.php b/yii/widgets/LinkPager.php index 1651246..2510579 100644 --- a/yii/widgets/LinkPager.php +++ b/yii/widgets/LinkPager.php @@ -122,7 +122,7 @@ class LinkPager extends Widget { $buttons = array(); - $pageCount = $this->pagination->pageCount; + $pageCount = $this->pagination->getPageCount(); $currentPage = $this->pagination->getPage(); // first page diff --git a/yii/widgets/ListPager.php b/yii/widgets/ListPager.php index a68b624..7b16f7d 100644 --- a/yii/widgets/ListPager.php +++ b/yii/widgets/ListPager.php @@ -63,7 +63,7 @@ class ListPager extends Widget */ public function run() { - $pageCount = $this->pagination->pageCount; + $pageCount = $this->pagination->getPageCount(); $currentPage = $this->pagination->getPage(); $pages = array(); From 986bfccd340d4f3775c4cbe48c42ab66664a9afc Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 16 May 2013 07:25:55 -0400 Subject: [PATCH 2/2] Fixes issue #294. --- tests/unit/framework/YiiBaseTest.php | 3 +++ yii/YiiBase.php | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/framework/YiiBaseTest.php b/tests/unit/framework/YiiBaseTest.php index bc31c0a..e256b2b 100644 --- a/tests/unit/framework/YiiBaseTest.php +++ b/tests/unit/framework/YiiBaseTest.php @@ -45,6 +45,9 @@ class YiiBaseTest extends TestCase Yii::setAlias('@yii', null); $this->assertFalse(Yii::getAlias('@yii', false)); $this->assertEquals('/yii/gii/file', Yii::getAlias('@yii/gii/file')); + + Yii::setAlias('@some/alias', '/www'); + $this->assertEquals('/www', Yii::getAlias('@some/alias')); } public function testGetVersion() diff --git a/yii/YiiBase.php b/yii/YiiBase.php index ce421d4..ad48e52 100644 --- a/yii/YiiBase.php +++ b/yii/YiiBase.php @@ -287,7 +287,11 @@ class YiiBase if ($path !== null) { $path = strncmp($path, '@', 1) ? rtrim($path, '\\/') : static::getAlias($path); if (!isset(self::$aliases[$root])) { - self::$aliases[$root] = $path; + if ($pos === false) { + self::$aliases[$root] = $path; + } else { + self::$aliases[$root] = array($alias => $path); + } } elseif (is_string(self::$aliases[$root])) { if ($pos === false) { self::$aliases[$root] = $path;