Merge pull request #2620 from LukeTowers/patch-12

Support nested components
This commit is contained in:
Samuel Georges 2017-01-21 11:23:36 +11:00 committed by GitHub
commit 1aada3c071
1 changed files with 11 additions and 5 deletions

View File

@ -978,15 +978,21 @@ class Controller
*/
public function renderComponent($name, $parameters = [])
{
$result = null;
$previousContext = $this->componentContext;
if ($componentObj = $this->findComponentByName($name)) {
$componentObj->id = uniqid($name);
$componentObj->setProperties(array_merge($componentObj->getProperties(), $parameters));
if ($result = $componentObj->onRender()) {
return $result;
}
$this->componentContext = $componentObj;
$result = $componentObj->onRender();
}
return $this->renderPartial($name.'::default', [], false);
if (!$result) {
$result = $this->renderPartial($name.'::default', [], false);
}
$this->componentContext = $previousContext;
return $result;
}
//