vendor/twig/extra-bundle/LeagueCommonMarkConverterFactory.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Twig.
  4.  *
  5.  * (c) Fabien Potencier
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Twig\Extra\TwigExtraBundle;
  11. use League\CommonMark\CommonMarkConverter;
  12. use League\CommonMark\Extension\ExtensionInterface;
  13. /**
  14.  * @internal
  15.  */
  16. final class LeagueCommonMarkConverterFactory
  17. {
  18.     private $extensions;
  19.     /**
  20.      * @param ExtensionInterface[] $extensions
  21.      */
  22.     public function __construct(iterable $extensions)
  23.     {
  24.         $this->extensions $extensions;
  25.     }
  26.     public function __invoke(): CommonMarkConverter
  27.     {
  28.         $converter = new CommonMarkConverter();
  29.         foreach ($this->extensions as $extension) {
  30.             $converter->getEnvironment()->addExtension($extension);
  31.         }
  32.         return $converter;
  33.     }
  34. }