src/Twig/ToolsExtension.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Services\Core\Tools;
  4. use Twig\Extension\AbstractExtension;
  5. use Twig\TwigFunction;
  6. use Twig\TwigFilter;
  7. class ToolsExtension extends AbstractExtension
  8. {
  9.     public function __construct(Tools $tools)
  10.     {
  11.         $this->tools $tools;
  12.     }
  13.     public function getFunctions(): array
  14.     {
  15.         return [
  16.             new  TwigFunction('getCoreToolsTag', [$this'getToolsTag']),
  17.             new  TwigFunction('getCoreTagCategory', [$this'getTagCategory']),
  18.             new  TwigFunction('getCoreToolsList', [$this'getCoreToolsList']),
  19.         ];
  20.     }
  21.     public function getFilters()
  22.     {
  23.         return [
  24.             new TwigFilter('clean_n', [$this'clean_n']),
  25.         ];
  26.     }
  27.     public function getCoreToolsList($category)
  28.     {
  29.         return $this->tools->getList($category);
  30.     }
  31.     public function getToolsTag($tag)
  32.     {
  33.         return $this->tools->getTag($tag);
  34.     }
  35.     public function getTagCategory($tag,$typeWebsite)
  36.     {
  37.         return $this->tools->getTagCategory($tag,$typeWebsite);
  38.     }
  39. }