<?php
namespace App\Twig;
use App\Entity\Category;
use App\Entity\Partner;
use App\Service\AppService;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Cofondateur\SocleTechniqueBundle\Twig\AppExtension as BaseAppExtension;
use Twig\TwigFunction;
class AppExtension extends BaseAppExtension
{
public function getFilters(): array
{
$result = parent::getFilters();
return $result;
}
public function getFunctions(): array
{
return [
new TwigFunction('getCategories', [$this, 'getCategories']),
new TwigFunction('getPartners', [$this, 'getPartners']),
new TwigFunction('getPage', [$this, 'getPage']),
new TwigFunction('getInfosLanding', [$this, 'getInfosLanding']),
new TwigFunction('decode_html_entities', [$this, 'decodeHtmlEntities']),
];
}
public function getCategories()
{
/** @var CategoryRepository $repo */
$repo = $this->em->getRepository(Category::class);
return $repo->findAll();
}
public function getPartners()
{
/** @var CategoryRepository $repo */
$repo = $this->em->getRepository(Partner::class);
return $repo->findAll();
}
public function getInfosLanding() {
return [
[
"title" => "Pharmacie & Laboratoire",
"image" => "pharmacie",
],
[
"title" => "Agenceur",
"image" => "agenceur",
],
[
"title" => "Optique",
"image" => "optique",
],
[
"title" => "Commerce",
"image" => "commerce",
],
[
"title" => "Industrie",
"image" => "industrie",
],
[
"title" => "Communiquants",
"image" => "communiquants",
],
];
}
public function decodeHtmlEntities($string)
{
return html_entity_decode($string, ENT_QUOTES, 'UTF-8');
}
}