From 6b15768a3f8613edaf611b13b4f55e3b60773ab6 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 19 Oct 2013 01:02:13 +0400 Subject: [PATCH] Better handling of trying to configure already instantiated component --- framework/yii/base/Module.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/framework/yii/base/Module.php b/framework/yii/base/Module.php index ee3949b..abf39ec 100644 --- a/framework/yii/base/Module.php +++ b/framework/yii/base/Module.php @@ -546,10 +546,15 @@ abstract class Module extends Component public function setComponents($components) { foreach ($components as $id => $component) { - if (isset($this->_components[$id]['class']) && !isset($component['class'])) { - $component['class'] = $this->_components[$id]['class']; + if (isset($this->_components[$id]) && !($this->_components[$id] instanceof Object)) { + if (isset($this->_components[$id]['class']) && !isset($component['class'])) { + $component['class'] = $this->_components[$id]['class']; + } + $this->_components[$id] = $component; + } + else { + throw new Exception('Cannot set component "'.$id.'" that is already instantiated.'); } - $this->_components[$id] = $component; } }