Merge pull request #2620 from LukeTowers/patch-12
Support nested components
This commit is contained in:
commit
1aada3c071
|
|
@ -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;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue