src/Twig/PagesExtension.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Services\Core\Core;
  4. use App\Services\Pages\Fiches;
  5. use App\Services\Pages\Templates;
  6. use Twig\Extension\AbstractExtension;
  7. use Twig\TwigFunction;
  8. use Twig\TwigFilter;
  9. class PagesExtension extends AbstractExtension
  10. {
  11.     public function __construct(Core $core,
  12.                                 Templates $templates,
  13.                                 Fiches $fiches
  14.     ) {
  15.         $this->core $core;
  16.         $this->templates $templates;
  17.         $this->fiches $fiches;
  18.     }
  19.     /**
  20.      * {@inheritdoc}
  21.      */
  22.     public function getFunctions(): array
  23.     {
  24.         return [
  25.             new  TwigFunction('getTemplatesFormSubItems', array($this'getTemplatesFormSubItems')),
  26.             new  TwigFunction('getExtensionFilename', array($this'getExtensionFilename')),
  27.             new  TwigFunction('numbersOfCharacters', array($this'numbersOfCharacters')),
  28.             new  TwigFunction('getCountInteractions', array($this'getCountInteractions')),
  29.             new  TwigFunction('getSaveHTML', array($this'getSaveHTML')),
  30.             new  TwigFunction('cleanSourcecodeHTML', array($this'cleanSourcecodeHTML')),
  31.             new  TwigFunction('cleanQcmHTML', array($this'cleanQcmHTML')),
  32.             new  TwigFunction('getSimulationCategoryItems', array($this'getSimulationCategoryItems')),
  33.         ];
  34.     }
  35.     public function getSimulationCategoryItems($categoryID)
  36.     {
  37.         return $this->fiches->getSimulationItems($categoryID);
  38.     }
  39.     public function cleanSourcecodeHTML($html)
  40.     {
  41.         return $this->templates->cleanSourcecodeHTML($html);
  42.     }
  43.     public function cleanQcmHTML($html)
  44.     {
  45.         return $this->templates->cleanQcmHTML($html);
  46.     }
  47.     public function getExtensionFilename($text)
  48.     {
  49.         return $this->core->extension($text);
  50.     }
  51.     public function numbersOfCharacters($chain)
  52.     {
  53.         return $this->core->numbersOfCharacters($chain);
  54.     }
  55.     public function getTemplatesFormSubItems($item)
  56.     {
  57.         return $this->templates->getTemplatesFormSubItems($item);
  58.     }
  59.     public function getSaveHTML($saveTemplate)
  60.     {
  61.         return $this->templates->getSaveHTML($saveTemplate);
  62.     }
  63.     public function getCountInteractions($interactionID)
  64.     {
  65.         return $this->fiches->getCountInteractions($interactionID);
  66.     }
  67. }