<?php
namespace App\Twig;
use App\Services\Core\Tools;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Twig\TwigFilter;
class ToolsExtension extends AbstractExtension
{
public function __construct(Tools $tools)
{
$this->tools = $tools;
}
public function getFunctions(): array
{
return [
new TwigFunction('getCoreToolsTag', [$this, 'getToolsTag']),
new TwigFunction('getCoreTagCategory', [$this, 'getTagCategory']),
new TwigFunction('getCoreToolsList', [$this, 'getCoreToolsList']),
];
}
public function getFilters()
{
return [
new TwigFilter('clean_n', [$this, 'clean_n']),
];
}
public function getCoreToolsList($category)
{
return $this->tools->getList($category);
}
public function getToolsTag($tag)
{
return $this->tools->getTag($tag);
}
public function getTagCategory($tag,$typeWebsite)
{
return $this->tools->getTagCategory($tag,$typeWebsite);
}
}