Better handling of trying to configure already instantiated component

This commit is contained in:
Alexander Makarov
2013-10-19 01:02:13 +04:00
parent 005c006b69
commit 6b15768a3f

View File

@@ -546,11 +546,16 @@ abstract class Module extends Component
public function setComponents($components)
{
foreach ($components as $id => $component) {
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.');
}
}
}
/**