Permalink
Browse files

`yii\debug\Module::defaultVersion()` implementation (#159)

`yii\debug\Module::defaultVersion()` implemented to pick up 'yiisoft/yii2-debug' extension version
  • Loading branch information...
1 parent ced039e commit 66b092fc030a80ee495403fc09e6f6d472edf20b @klimov-paul klimov-paul committed on GitHub Oct 26, 2016
Showing with 29 additions and 0 deletions.
  1. +1 −0 CHANGELOG.md
  2. +15 −0 Module.php
  3. +1 −0 composer.json
  4. +12 −0 tests/ModuleTest.php
View
@@ -5,6 +5,7 @@ Yii Framework 2 debug extension Change Log
-----------------------
- Enh: Mouse wheel click, or Ctrl+Click opens debugger in new tab (silverfire)
+- Enh: `yii\debug\Module::defaultVersion()` implemented to pick up 'yiisoft/yii2-debug' extension version (klimov-paul)
- Bug #99: Avoid serializing php7 errors (zuozp8)
- Bug #111: Fixed `LogTarget` to work properly when tests are ran via Codeception (samdark, nlmedina)
- Bug #120: Fixed toolbar height changing when opened/closed and when using bootstrap (nkovacs)
View
@@ -10,6 +10,7 @@
use Yii;
use yii\base\Application;
use yii\base\BootstrapInterface;
+use yii\helpers\Json;
use yii\web\Response;
use yii\helpers\Html;
use yii\helpers\Url;
@@ -311,4 +312,18 @@ protected function corePanels()
'timeline' => ['class' => 'yii\debug\panels\TimelinePanel']
];
}
+
+ /**
+ * @inheritdoc
+ * @since 2.0.7
+ */
+ protected function defaultVersion()
+ {
+ $packageInfo = Json::decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'composer.json'));
+ $extensionName = $packageInfo['name'];
+ if (isset(Yii::$app->extensions[$extensionName])) {
+ return Yii::$app->extensions[$extensionName]['version'];
+ }
+ return parent::defaultVersion();
+ }
}
View
@@ -17,6 +17,7 @@
"email": "qiang.xue@gmail.com"
}
],
+ "minimum-stability": "dev",
"require": {
"yiisoft/yii2": "~2.0.4",
"yiisoft/yii2-bootstrap": "~2.0.0"
View
@@ -108,4 +108,16 @@ public function testNonCachedToolbarHtml()
}
$this->assertNotEquals($output[0],$output[1]);
}
+
+ public function testDefaultVersion()
+ {
+ Yii::$app->extensions['yiisoft/yii2-debug'] = [
+ 'name' => 'yiisoft/yii2-debug',
+ 'version' => '2.0.7',
+ ];
+
+ $module = new Module('debug');
+
+ $this->assertEquals('2.0.7', $module->getVersion());
+ }
}

0 comments on commit 66b092f

Please sign in to comment.