You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.0KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Twig;
  3. use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
  4. use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
  5. use Twig\Extension\AbstractExtension;
  6. use Twig\TwigFunction;
  7. class StoreTwigExtension extends AbstractExtension
  8. {
  9. protected $merchantRepository;
  10. protected $sectionRepository;
  11. public function __construct(
  12. MerchantRepositoryQuery $merchantRepository,
  13. SectionRepositoryInterface $sectionRepository
  14. ) {
  15. $this->merchantRepository = $merchantRepository;
  16. $this->sectionRepository = $sectionRepository;
  17. }
  18. public function getFunctions()
  19. {
  20. return array(
  21. new TwigFunction('carac_sections', [$this, 'getSections']),
  22. new TwigFunction('carac_merchants', [$this, 'getMerchants']),
  23. );
  24. }
  25. public function getSections()
  26. {
  27. return $this->sectionRepository->findAll();
  28. }
  29. public function getMerchants()
  30. {
  31. return $this->merchantRepository->findAll();
  32. }
  33. }