From e8eccc281d79b0186b1d2ad3298f8ccf100989fc Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 19 Oct 2013 02:01:58 +0400 Subject: [PATCH] Refactored instanceof in Module into method in Application --- framework/yii/base/Application.php | 14 ++++++++++++++ framework/yii/base/Module.php | 12 ++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/framework/yii/base/Application.php b/framework/yii/base/Application.php index d92b05c..b3803cb 100644 --- a/framework/yii/base/Application.php +++ b/framework/yii/base/Application.php @@ -172,6 +172,20 @@ abstract class Application extends Module } /** + * Initializes the application. + * This method is called after the application is created and initialized with property values + * given in configuration. + */ + public function init() + { + $this->preloadComponents(); + if ($this->controllerNamespace === null) { + $this->controllerNamespace = 'app\\controllers'; + } + } + + + /** * Loads components that are declared in [[preload]]. * @throws InvalidConfigException if a component or module to be preloaded is unknown */ diff --git a/framework/yii/base/Module.php b/framework/yii/base/Module.php index abf39ec..8e62d0a 100644 --- a/framework/yii/base/Module.php +++ b/framework/yii/base/Module.php @@ -167,20 +167,16 @@ abstract class Module extends Component /** * Initializes the module. * This method is called after the module is created and initialized with property values - * given in configuration. The default implement will create a path alias using the module [[id]] + * given in configuration. The default implementation will create a path alias using the module [[id]] * and then call [[preloadComponents()]] to load components that are declared in [[preload]]. */ public function init() { $this->preloadComponents(); if ($this->controllerNamespace === null) { - if ($this instanceof Application) { - $this->controllerNamespace = 'app\\controllers'; - } else { - $class = get_class($this); - if (($pos = strrpos($class, '\\')) !== false) { - $this->controllerNamespace = substr($class, 0, $pos) . '\\controllers'; - } + $class = get_class($this); + if (($pos = strrpos($class, '\\')) !== false) { + $this->controllerNamespace = substr($class, 0, $pos) . '\\controllers'; } } }