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.

64 lines
1.8KB

  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\TwigFilter;
  8. use Twig\TwigFunction;
  9. class BridgeTwigExtension extends AbstractExtension
  10. {
  11. private $utils ;
  12. public function __construct(Utils $utils)
  13. {
  14. $this->utils = $utils ;
  15. }
  16. public function getFunctions()
  17. {
  18. return array(
  19. new TwigFunction('getDayByNumber', [$this, 'getDayByNumber']),
  20. new TwigFunction('getUnitsList', [$this, 'getUnitsList']),
  21. new TwigFunction('getTaxRatesList', [$this, 'getTaxRatesList']),
  22. new TwigFunction('getElementByDevAlias', [$this, 'getElementByDevAlias']),
  23. new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']),
  24. );
  25. }
  26. public function getFilters()
  27. {
  28. return [
  29. new TwigFilter('slugify', [$this, 'slugify']),
  30. ];
  31. }
  32. public function getDayByNumber($number)
  33. {
  34. return $this->utils->getDayByNumber($number) ;
  35. }
  36. public function getUnitsList()
  37. {
  38. return $this->utils->getUnitsList() ;
  39. }
  40. public function getTaxRatesList()
  41. {
  42. return $this->utils->getTaxRatesList() ;
  43. }
  44. public function getElementByDevAlias($devAlias, $class = PageInterface::class)
  45. {
  46. return $this->utils->getElementByDevAlias($devAlias, $class) ;
  47. }
  48. public function slugify($string)
  49. {
  50. return $this->utils->slugify($string) ;
  51. }
  52. }