|
- <?php
-
- namespace Lc\ShopBundle\Twig;
-
- use Lc\ShopBundle\Context\PageInterface;
- use Lc\ShopBundle\Services\Utils;
- use Twig\Extension\AbstractExtension;
- use Twig\TwigFunction;
-
- class BridgeTwigExtension extends AbstractExtension
- {
- private $utils ;
-
- public function __construct(Utils $utils)
- {
- $this->utils = $utils ;
- }
-
- public function getFunctions()
- {
- return array(
- new TwigFunction('getDayByNumber', [$this, 'getDayByNumber']),
- new TwigFunction('getUnitsList', [$this, 'getUnitsList']),
- new TwigFunction('getElementByDevAlias', [$this, 'getElementByDevAlias']),
- );
- }
-
- public function getFilters()
- {
- return [
- ];
- }
-
- public function getDayByNumber($number)
- {
- return $this->utils->getDayByNumber($number) ;
- }
-
- public function getUnitsList()
- {
- return $this->utils->getUnitsList() ;
- }
-
- public function getElementByDevAlias($devAlias, $class = PageInterface::class)
- {
- return $this->utils->getElementByDevAlias($devAlias, $class) ;
- }
- }
|