<?php
namespace App\Twig;
use App\Services\Core\Core;
use App\Services\Pages\Fiches;
use App\Services\Pages\Templates;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Twig\TwigFilter;
class PagesExtension extends AbstractExtension
{
public function __construct(Core $core, Templates $templates)
{
$this->core = $core;
$this->templates = $templates;
}
/**
* {@inheritdoc}
*/
public function getFunctions(): array
{
return [
new TwigFunction('getTemplatesFormSubItems', array($this, 'getTemplatesFormSubItems')),
new TwigFunction('getExtensionFilename', array($this, 'getExtensionFilename')),
new TwigFunction('numbersOfCharacters', array($this, 'numbersOfCharacters')),
new TwigFunction('getCountInteractions', array($this, 'getCountInteractions')),
new TwigFunction('getSaveHTML', array($this, 'getSaveHTML')),
new TwigFunction('cleanSourcecodeHTML', array($this, 'cleanSourcecodeHTML')),
new TwigFunction('cleanQcmHTML', array($this, 'cleanQcmHTML')),
new TwigFunction('getPageHasLanguages', array($this, 'getPageHasLanguages')),
new TwigFunction('getPagesHasLocale', array($this, 'getPagesHasLocale')),
new TwigFunction('getPathPageHasLanguages', array($this, 'getPathPageHasLanguages')),
new TwigFunction('getArticleAriane', array($this, 'getArticleAriane')),
new TwigFunction('autosummary', array($this, 'autosummary')),
new TwigFunction('autosummaryID', array($this, 'autosummaryID')),
new TwigFunction('getPageIdentifiant', array($this, 'getPageIdentifiant')),
new TwigFunction('getPathCategoryHasLanguages', array($this, 'getPathCategoryHasLanguages')),
new TwigFunction('getPathCategoryRecruiterDirectoryHasLanguages', array($this, 'getPathCategoryRecruiterDirectoryHasLanguages')),
];
}
public function getPageIdentifiant($identifiant, $locale = "en") {
return $this->templates->getPageIdentifiant($identifiant,$locale);
}
public function autosummary($html)
{
return $this->templates->autosummary($html);
}
public function autosummaryID($html)
{
return $this->templates->autosummaryID($html);
}
public function getArticleAriane($locale,$folderslug,$folderslug2 = null,$folderslug3 = null)
{
return $this->templates->getArticleAriane($locale,$folderslug,$folderslug2,$folderslug3);
}
public function getPathPageHasLanguages($pageID,$language)
{
return $this->templates->getPathPageHasLanguages($pageID,$language);
}
public function getPathCategoryHasLanguages($categoryID,$language)
{
return $this->templates->getPathCategoryHasLanguages($categoryID,$language);
}
public function getPathCategoryRecruiterDirectoryHasLanguages($categoryID,$language)
{
return $this->templates->getPathCategoryRecruiterDirectoryHasLanguages($categoryID,$language);
}
public function getPageHasLanguages($pageID,$language)
{
$queries = $this->templates->getPageHasLanguages($pageID,$language);
if(!empty($queries)) {
return $queries;
}
return null;
}
public function getPagesHasLocale($language)
{
return $this->templates->getPagesHasLocale($language);
}
public function cleanSourcecodeHTML($html)
{
return $this->templates->cleanSourcecodeHTML($html);
}
public function cleanQcmHTML($html)
{
return $this->templates->cleanQcmHTML($html);
}
public function getExtensionFilename($text)
{
return $this->core->extension($text);
}
public function numbersOfCharacters($chain)
{
return $this->core->numbersOfCharacters($chain);
}
public function getTemplatesFormSubItems($item)
{
return $this->templates->getTemplatesFormSubItems($item);
}
public function getSaveHTML($saveTemplate)
{
return $this->templates->getSaveHTML($saveTemplate);
}
}