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.

51 lines
1.4KB

  1. <?php
  2. namespace Lc\ShopBundle\Twig;
  3. use Lc\ShopBundle\Context\PageInterface;
  4. use Lc\ShopBundle\Form\Frontend\NewsletterType;
  5. use Lc\ShopBundle\Services\Utils;
  6. use Twig\Extension\AbstractExtension;
  7. use Twig\TwigFunction;
  8. class BridgeTwigExtension extends AbstractExtension
  9. {
  10. private $utils ;
  11. public function __construct(Utils $utils)
  12. {
  13. $this->utils = $utils ;
  14. }
  15. public function getFunctions()
  16. {
  17. return array(
  18. new TwigFunction('getDayByNumber', [$this, 'getDayByNumber']),
  19. new TwigFunction('getUnitsList', [$this, 'getUnitsList']),
  20. new TwigFunction('getElementByDevAlias', [$this, 'getElementByDevAlias']),
  21. new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']),
  22. );
  23. }
  24. public function getFilters()
  25. {
  26. return [
  27. ];
  28. }
  29. public function getDayByNumber($number)
  30. {
  31. return $this->utils->getDayByNumber($number) ;
  32. }
  33. public function getUnitsList()
  34. {
  35. return $this->utils->getUnitsList() ;
  36. }
  37. public function getElementByDevAlias($devAlias, $class = PageInterface::class)
  38. {
  39. return $this->utils->getElementByDevAlias($devAlias, $class) ;
  40. }
  41. }