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

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.  *
  17.  * @experimental
  18.  */
  19. final class TraceableTemplateBlockRenderer implements TemplateBlockRendererInterface
  20. {
  21.     public function __construct(
  22.         private TemplateBlockRendererInterface $templateBlockRenderer,
  23.         private TemplateBlockRenderingHistory $templateBlockRenderingHistory,
  24.     ) {
  25.     }
  26.     public function render(TemplateBlock $templateBlock, array $context = []): string
  27.     {
  28.         $this->templateBlockRenderingHistory->startRenderingBlock($templateBlock$context);
  29.         $renderedBlock $this->templateBlockRenderer->render($templateBlock$context);
  30.         $this->templateBlockRenderingHistory->stopRenderingBlock($templateBlock$context);
  31.         return $renderedBlock;
  32.     }
  33. }