<?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,
Fiches $fiches
) {
$this->core = $core;
$this->templates = $templates;
$this->fiches = $fiches;
}
/**
* {@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('getSimulationCategoryItems', array($this, 'getSimulationCategoryItems')),
];
}
public function getSimulationCategoryItems($categoryID)
{
return $this->fiches->getSimulationItems($categoryID);
}
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);
}
public function getCountInteractions($interactionID)
{
return $this->fiches->getCountInteractions($interactionID);
}
}