vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/DataCollector/TraceableTemplateBlockRenderer.php line 35

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\UiBundle\DataCollector;
  12. use Sylius\Bundle\UiBundle\Registry\TemplateBlock;
  13. use Sylius\Bundle\UiBundle\Renderer\TemplateBlockRendererInterface;
  14. /**
  15.  * @internal
  16.  * @experimental
  17.  */
  18. final class TraceableTemplateBlockRenderer implements TemplateBlockRendererInterface
  19. {
  20.     private TemplateBlockRendererInterface $templateBlockRenderer;
  21.     private TemplateBlockRenderingHistory $templateBlockRenderingHistory;
  22.     public function __construct(TemplateBlockRendererInterface $templateBlockRendererTemplateBlockRenderingHistory $templateBlockRenderingHistory)
  23.     {
  24.         $this->templateBlockRenderer $templateBlockRenderer;
  25.         $this->templateBlockRenderingHistory $templateBlockRenderingHistory;
  26.     }
  27.     public function render(TemplateBlock $templateBlock, array $context = []): string
  28.     {
  29.         $this->templateBlockRenderingHistory->startRenderingBlock($templateBlock$context);
  30.         $renderedBlock $this->templateBlockRenderer->render($templateBlock$context);
  31.         $this->templateBlockRenderingHistory->stopRenderingBlock($templateBlock$context);
  32.         return $renderedBlock;
  33.     }
  34. }