src/Twig/AppExtension.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Entity\Category;
  4. use App\Entity\Partner;
  5. use App\Service\AppService;
  6. use Twig\Extension\AbstractExtension;
  7. use Twig\TwigFilter;
  8. use Cofondateur\SocleTechniqueBundle\Twig\AppExtension as BaseAppExtension;
  9. use Twig\TwigFunction;
  10. class AppExtension extends BaseAppExtension
  11. {
  12.     public function getFilters(): array
  13.     {
  14.         $result parent::getFilters();
  15.         return $result;
  16.     }
  17.     public function getFunctions(): array
  18.     {
  19.         return [
  20.             new TwigFunction('getCategories', [$this'getCategories']),
  21.             new TwigFunction('getPartners', [$this'getPartners']),
  22.             new TwigFunction('getPage', [$this'getPage']),
  23.             new TwigFunction('getInfosLanding', [$this'getInfosLanding']),
  24.             new TwigFunction('decode_html_entities', [$this'decodeHtmlEntities']),
  25.         ];
  26.     }
  27.     public function getCategories()
  28.     {
  29.         /** @var CategoryRepository $repo */
  30.         $repo $this->em->getRepository(Category::class);
  31.         return $repo->findAll();
  32.     }
  33.     public function getPartners()
  34.     {
  35.         /** @var CategoryRepository $repo */
  36.         $repo $this->em->getRepository(Partner::class);
  37.         return $repo->findAll();
  38.     }
  39.     
  40.      public function getInfosLanding() {
  41.         return [
  42.                 [
  43.                 "title" => "Pharmacie & Laboratoire",
  44.                 "image" => "pharmacie",
  45.             ],
  46.                 [
  47.                 "title" => "Agenceur",
  48.                 "image" => "agenceur",
  49.             ],
  50.                 [
  51.                 "title" => "Optique",
  52.                 "image" => "optique",
  53.             ],
  54.                 [
  55.                 "title" => "Commerce",
  56.                 "image" => "commerce",
  57.             ],
  58.                 [
  59.                 "title" => "Industrie",
  60.                 "image" => "industrie",
  61.             ],
  62.                 [
  63.                 "title" => "Communiquants",
  64.                 "image" => "communiquants",
  65.             ],
  66.       
  67.         ];
  68.     }
  69.     public function decodeHtmlEntities($string)
  70.     {
  71.         return html_entity_decode($stringENT_QUOTES'UTF-8');
  72.     }
  73. }