49 lines
1.2KB

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