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.

57 lines
1.6KB

  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('getTaxRatesList', [$this, 'getTaxRatesList']),
  21. new TwigFunction('getElementByDevAlias', [$this, 'getElementByDevAlias']),
  22. new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']),
  23. );
  24. }
  25. public function getFilters()
  26. {
  27. return [
  28. ];
  29. }
  30. public function getDayByNumber($number)
  31. {
  32. return $this->utils->getDayByNumber($number) ;
  33. }
  34. public function getUnitsList()
  35. {
  36. return $this->utils->getUnitsList() ;
  37. }
  38. public function getTaxRatesList()
  39. {
  40. return $this->utils->getTaxRatesList() ;
  41. }
  42. public function getElementByDevAlias($devAlias, $class = PageInterface::class)
  43. {
  44. return $this->utils->getElementByDevAlias($devAlias, $class) ;
  45. }
  46. }