src/Twig/PagesExtension.php line 15

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.             new  TwigFunction('getArticleAriane', array($this'getArticleAriane')),
  34.             new  TwigFunction('getPageHasLanguages', array($this'getPageHasLanguages')),
  35.             new  TwigFunction('getPagesHasLocale', array($this'getPagesHasLocale')),
  36.             new  TwigFunction('getPathPageHasLanguages', array($this'getPathPageHasLanguages')),
  37.             new  TwigFunction('autosummary', array($this'autosummary')),
  38.             new  TwigFunction('autosummaryID', array($this'autosummaryID')),
  39.             new  TwigFunction('getPageIdentifiant', array($this'getPageIdentifiant')),
  40.             new  TwigFunction('getPathArticleLocale', array($this'getPathArticleLocale')),
  41.         ];
  42.     }
  43.     public function getPathArticleLocale($locale,$identifiant)
  44.     {
  45.         return $this->fiches->getArticleIdentifiant($locale,$identifiant);
  46.     }
  47.     public function getArticleAriane($folderslug,$folderslug2 null,$folderslug3 null)
  48.     {
  49.         return $this->fiches->getArticleAriane($folderslug,$folderslug2,$folderslug3);
  50.     }
  51.     public function getSimulationCategoryItems($categoryID)
  52.     {
  53.         return $this->fiches->getSimulationItems($categoryID);
  54.     }
  55.     public function cleanSourcecodeHTML($html)
  56.     {
  57.         return $this->templates->cleanSourcecodeHTML($html);
  58.     }
  59.     public function cleanQcmHTML($html)
  60.     {
  61.         return $this->templates->cleanQcmHTML($html);
  62.     }
  63.     public function getExtensionFilename($text)
  64.     {
  65.         return $this->core->extension($text);
  66.     }
  67.     public function numbersOfCharacters($chain)
  68.     {
  69.         return $this->core->numbersOfCharacters($chain);
  70.     }
  71.     public function getTemplatesFormSubItems($item)
  72.     {
  73.         return $this->templates->getTemplatesFormSubItems($item);
  74.     }
  75.     public function getSaveHTML($saveTemplate)
  76.     {
  77.         return $this->templates->getSaveHTML($saveTemplate);
  78.     }
  79.     public function getCountInteractions($interactionID)
  80.     {
  81.         return $this->fiches->getCountInteractions($interactionID);
  82.     }
  83.     public function getPageHasLanguages($pageID,$language)
  84.     {
  85.         $queries $this->templates->getPageHasLanguages($pageID,$language);
  86.         if(!empty($queries)) {
  87.             return $queries;
  88.         }
  89.         return null;
  90.     }
  91.     public function getPagesHasLocale($language)
  92.     {
  93.         return $this->templates->getPagesHasLocale($language);
  94.     }
  95.     public function getPathPageHasLanguages($pageID,$language)
  96.     {
  97.         return $this->templates->getPathPageHasLanguages($pageID,$language);
  98.     }
  99.     public function getPageIdentifiant($identifiant$locale "en") {
  100.         return $this->templates->getPageIdentifiant($identifiant,$locale);
  101.     }
  102.     public function autosummary($html)
  103.     {
  104.         return $this->templates->autosummary($html);
  105.     }
  106.     public function autosummaryID($html)
  107.     {
  108.         return $this->templates->autosummaryID($html);
  109.     }
  110. }