Completed
Push — new-template-events-architectu... ( 533634 )
by Kamil
05:23
created

TemplateEventExtension::renderBlocksForEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\Bundle\UiBundle\Twig;
6
7
use Sonata\BlockBundle\Templating\Helper\BlockHelper;
8
use Twig\Extension\AbstractExtension;
9
use Twig\TwigFunction;
10
11
/**
12
 * Proxy extension for rendering blocks for an event - currently uses Sonata, might change in the future.
13
 */
14
final class TemplateEventExtension extends AbstractExtension
15
{
16
    /** @var BlockHelper */
17
    private $blockHelper;
18
19
    public function __construct(BlockHelper $blockHelper)
20
    {
21
        $this->blockHelper = $blockHelper;
22
    }
23
24
    public function getFunctions(): array
25
    {
26
        return [
27
            new TwigFunction('sylius_template_event', [$this, 'renderBlocksForEvent'], ['is_safe' => ['html']]),
28
        ];
29
    }
30
31
    public function renderBlocksForEvent(string $event, array $options = []): string
32
    {
33
        return $this->blockHelper->renderEvent($event, $options);
34
    }
35
}
36