block builder: add test to check if the widget exists

This commit is contained in:
Simon Vieille 2024-05-14 22:13:36 +02:00
parent 4acba618cb
commit b680946daf
Signed by: deblan
GPG key ID: 579388D585F70417
2 changed files with 9 additions and 0 deletions

View file

@ -20,6 +20,11 @@ class BuilderBlockContainer
return $this->widgets;
}
public function hasWidget(string $name)
{
return isset($this->widgets[$name]);
}
public function getWidget(string $name): BuilderBlock
{
return $this->widgets[$name];

View file

@ -30,6 +30,10 @@ class BuilderExtension extends AbstractExtension
}
if (isset($data['widget'])) {
if (!$this->container->hasWidget($data['widget'])) {
return '';
}
$widget = $this->container->getWidget($data['widget']);
$widget->buildVars($data);