Completed
Push — master ( 52cd2c...047880 )
by Kamil
47:26 queued 26:32
created

TraceableTemplateBlockRenderer::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sylius\Bundle\UiBundle\DataCollector;
15
16
use Sylius\Bundle\UiBundle\Registry\TemplateBlock;
17
use Sylius\Bundle\UiBundle\Renderer\TemplateBlockRendererInterface;
18
19
/**
20
 * @internal
21
 */
22
final class TraceableTemplateBlockRenderer implements TemplateBlockRendererInterface
23
{
24
    /** @var TemplateBlockRendererInterface */
25
    private $templateBlockRenderer;
26
27
    /** @var TemplateBlockRenderingHistory */
28
    private $templateBlockRenderingHistory;
29
30
    public function __construct(TemplateBlockRendererInterface $templateBlockRenderer, TemplateBlockRenderingHistory $templateBlockRenderingHistory)
31
    {
32
        $this->templateBlockRenderer = $templateBlockRenderer;
33
        $this->templateBlockRenderingHistory = $templateBlockRenderingHistory;
34
    }
35
36
    public function render(string $eventName, TemplateBlock $templateBlock, array $context = []): string
37
    {
38
        $this->templateBlockRenderingHistory->startRenderingBlock($eventName, $templateBlock, $context);
39
40
        $renderedBlock = $this->templateBlockRenderer->render($eventName, $templateBlock, $context);
41
42
        $this->templateBlockRenderingHistory->stopRenderingBlock($eventName, $templateBlock, $context);
43
44
        return $renderedBlock;
45
    }
46
}
47