|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
-
- namespace Lc\ShopBundle\Twig;
-
- use Lc\ShopBundle\Context\PageInterface;
- use Lc\ShopBundle\Form\Frontend\NewsletterType;
- use Lc\ShopBundle\Services\TaxRateUtils;
- use Lc\ShopBundle\Services\UnitUtils;
- use Lc\ShopBundle\Services\Utils;
- use Twig\Extension\AbstractExtension;
- use Twig\TwigFilter;
- use Twig\TwigFunction;
-
- class BridgeTwigExtension extends AbstractExtension
- {
- private $utils ;
- private $taxRateUtils ;
- private $unitUtils ;
-
- public function __construct(Utils $utils, TaxRateUtils $taxRateUtils, UnitUtils $unitUtils)
- {
- $this->utils = $utils ;
- $this->taxRateUtils = $taxRateUtils ;
- $this->unitUtils = $unitUtils ;
- }
-
- public function getFunctions()
- {
- return array(
- new TwigFunction('getDayByNumber', [$this, 'getDayByNumber']),
- new TwigFunction('getUnitsList', [$this, 'getUnitsList']),
- new TwigFunction('getTaxRatesList', [$this, 'getTaxRatesList']),
- new TwigFunction('getElementByDevAlias', [$this, 'getElementByDevAlias']),
- new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']),
- );
- }
-
- public function getFilters()
- {
- return [
- new TwigFilter('slugify', [$this, 'slugify']),
- ];
- }
-
- public function getDayByNumber($number)
- {
- return $this->utils->getDayByNumber($number) ;
- }
-
- public function getUnitsList()
- {
- return $this->unitUtils->getUnitsList() ;
- }
-
- public function getTaxRatesList()
- {
- return $this->taxRateUtils->getTaxRatesList() ;
- }
-
- public function getElementByDevAlias($devAlias, $class = PageInterface::class)
- {
- return $this->utils->getElementByDevAlias($devAlias, $class) ;
- }
-
- public function slugify($string)
- {
- return $this->utils->slugify($string) ;
- }
- }
|