src/Twig/ArticlesExtension.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Services\Articles;
  4. use Twig\Extension\AbstractExtension;
  5. use Twig\TwigFilter;
  6. use Twig\TwigFunction;
  7. class ArticlesExtension extends AbstractExtension
  8. {
  9.     public function __construct(Articles $articles)
  10.     {
  11.         $this->articles $articles;
  12.     }
  13.     /**
  14.      * {@inheritdoc}
  15.      */
  16.     public function getFunctions(): array
  17.     {
  18.         return [
  19.             new  TwigFunction('articleResumeChain', [$this'articleResumeChain']),
  20.             new  TwigFunction('forTags', [$this'forTags']),
  21.             new  TwigFunction('rewriteTag', [$this'rewriteTag']),
  22.             new  TwigFunction('reverseRewriteTag', [$this'reverseRewriteTag']),
  23.             new  TwigFunction('getArticles', [$this'getArticles']),
  24.         ];
  25.     }
  26.     public function getArticles($locale,$number)
  27.     {
  28.         return $this->articles->getLast($locale,$number);
  29.     }
  30.     public function articleResumeChain($chain,$numbers)
  31.     {
  32.         return $this->articles->resumeDescription($chain,$numbers);
  33.     }
  34.     public function forTags($tags)
  35.     {
  36.         return $this->articles->forTags($tags);
  37.     }
  38.     public function rewriteTag($tag)
  39.     {
  40.         return $this->articles->rewriteTag($tag);
  41.     }
  42.     public function reverseRewriteTag($tag)
  43.     {
  44.         return $this->articles->reverseRewriteTag($tag);
  45.     }
  46. }