Add better exception handling for non existent components

This commit is contained in:
Sam Georges 2014-05-30 21:25:23 +10:00
parent 9671d7d1e2
commit 394075041c
1 changed files with 6 additions and 2 deletions

View File

@ -265,12 +265,16 @@ class Controller extends BaseController
$manager = ComponentManager::instance();
if ($addToLayout) {
$componentObj = $manager->makeComponent($name, $this->layoutObj, $properties);
if (!$componentObj = $manager->makeComponent($name, $this->layoutObj, $properties))
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
$componentObj->alias = $alias;
$this->vars[$alias] = $this->layout->components[$alias] = $componentObj;
}
else {
$componentObj = $manager->makeComponent($name, $this->pageObj, $properties);
if (!$componentObj = $manager->makeComponent($name, $this->pageObj, $properties))
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
$componentObj->alias = $alias;
$this->vars[$alias] = $this->page->components[$alias] = $componentObj;
}