Merge branch 'develop'
This commit is contained in:
commit
c6cbc405e4
|
@ -10,6 +10,7 @@ abstract class BuilderBlock
|
|||
protected ?string $category = null;
|
||||
protected array $settings = [];
|
||||
protected array $widgets = [];
|
||||
protected array $vars = [];
|
||||
protected string $template = '';
|
||||
protected bool $isContainer = false;
|
||||
protected ?string $icon = null;
|
||||
|
@ -169,4 +170,13 @@ abstract class BuilderBlock
|
|||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
public function buildVars(array $data)
|
||||
{
|
||||
}
|
||||
|
||||
public function getVars(): array
|
||||
{
|
||||
return $this->vars;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use Twig\Environment;
|
|||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
class BuilderBlockExtension extends AbstractExtension
|
||||
class BuilderExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(protected Environment $twig, protected BuilderBlockContainer $container)
|
||||
{
|
||||
|
@ -30,10 +30,14 @@ class BuilderBlockExtension extends AbstractExtension
|
|||
}
|
||||
|
||||
if (isset($data['widget'])) {
|
||||
return $this->twig->render($this->container->getWidget($data['widget'])->getTemplate(), [
|
||||
$widget = $this->container->getWidget($data['widget']);
|
||||
$widget->buildVars($data);
|
||||
|
||||
return $this->twig->render($widget->getTemplate(), [
|
||||
'id' => $data['id'],
|
||||
'settings' => $data['settings'],
|
||||
'children' => $data['children'],
|
||||
'vars' => $widget->getVars(),
|
||||
]);
|
||||
}
|
||||
|
Loading…
Reference in a new issue