vendor/omines/datatables-bundle/src/Twig/TwigRenderer.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3.  * Symfony DataTables Bundle
  4.  * (c) Omines Internetbureau B.V. - https://omines.nl/
  5.  *
  6.  * For the full copyright and license information, please view the LICENSE
  7.  * file that was distributed with this source code.
  8.  */
  9. declare(strict_types=1);
  10. namespace Omines\DataTablesBundle\Twig;
  11. use Omines\DataTablesBundle\DataTable;
  12. use Omines\DataTablesBundle\DataTableRendererInterface;
  13. use Omines\DataTablesBundle\Exception\MissingDependencyException;
  14. use Twig\Environment;
  15. /**
  16.  * TwigRenderer.
  17.  *
  18.  * @author Niels Keurentjes <niels.keurentjes@omines.com>
  19.  */
  20. class TwigRenderer implements DataTableRendererInterface
  21. {
  22.     /** @var Environment */
  23.     private $twig;
  24.     public function __construct(Environment $twig null)
  25.     {
  26.         if (null === ($this->twig $twig)) {
  27.             throw new MissingDependencyException('You must have symfony/twig-bundle installed to use the default Twig based DataTables rendering');
  28.         }
  29.     }
  30.     /**
  31.      * {@inheritdoc}
  32.      */
  33.     public function renderDataTable(DataTable $dataTablestring $template, array $parameters): string
  34.     {
  35.         $parameters['datatable'] = $dataTable;
  36.         return $this->twig->render($template$parameters);
  37.     }
  38. }