src/Service/Common/Owner/TwigFunctions.php line 32

  1. <?php
  2. namespace App\Service\Common\Owner;
  3. use App\Model\Common\GetOwnerInterface;
  4. use App\Model\Common\HaveOwnerInterface;
  5. use Twig\Extension\AbstractExtension;
  6. use Twig\TwigFilter;
  7. class TwigFunctions extends AbstractExtension
  8. {
  9.     /**
  10.      * @var Render
  11.      */
  12.     private Render $render;
  13.     public function __construct(Render $render)
  14.     {
  15.         $this->render $render;
  16.     }
  17.     public function getFilters(): array
  18.     {
  19.         return [
  20.             new TwigFilter('owner_render', [$this'owner_render'], array('is_safe' => array('html'))),
  21.         ];
  22.     }
  23.     /**
  24.      * @throws \Exception
  25.      */
  26.     public function owner_render(GetOwnerInterface $itemstring $target, array $context = []): ?string
  27.     {
  28.         return $this->render->render($item$target$context);
  29.     }
  30. }