|
- <?php
-
- namespace Lc\CaracoleBundle\Twig;
-
- use Lc\CaracoleBundle\Repository\Config\TaxRateStore;
- use Lc\CaracoleBundle\Repository\Config\UnitStore;
- use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
- use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
- use Lc\CaracoleBundle\Repository\Reminder\ReminderStore;
- use Lc\CaracoleBundle\Repository\Section\SectionRepository;
- use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
- use Lc\CaracoleBundle\Repository\Section\SectionRepositoryQuery;
- use Lc\CaracoleBundle\Repository\Section\SectionStore;
- use Lc\CaracoleBundle\Resolver\MerchantResolver;
- use Lc\CaracoleBundle\Resolver\SectionResolver;
- use Lc\ShopBundle\Context\UnitInterface;
- use Twig\Extension\AbstractExtension;
- use Twig\TwigFunction;
-
- class StoreTwigExtension extends AbstractExtension
- {
- protected MerchantStore $merchantStore;
- protected SectionStore $sectionStore;
- protected ReminderStore $reminderStore;
- protected MerchantResolver $merchantResolver;
- protected SectionResolver $sectionResolver;
- protected UnitStore $unitStore;
- protected TaxRateStore $taxRateStore;
-
- public function __construct(
- MerchantResolver $merchantResolver,
- SectionResolver $sectionResolver,
- MerchantStore $merchantStore,
- SectionStore $sectionStore,
- ReminderStore $reminderStore,
- UnitStore $unitStore,
- TaxRateStore $taxRateStore
- ) {
- $this->merchantResolver = $merchantResolver;
- $this->sectionResolver = $sectionResolver;
- $this->merchantStore = $merchantStore;
- $this->sectionStore = $sectionStore;
- $this->reminderStore = $reminderStore;
- $this->unitStore = $unitStore;
- $this->taxRateStore = $taxRateStore;
- }
-
- public function getFunctions()
- {
- return array(
- new TwigFunction('carac_sections', [$this, 'getSections']),
- new TwigFunction('carac_merchants', [$this, 'getMerchants']),
- new TwigFunction('carac_reminders', [$this, 'getReminders']),
- new TwigFunction('carac_units', [$this, 'getUnits']),
- new TwigFunction('carac_tax_rates', [$this, 'getTaxRates']),
- new TwigFunction('carac_reduction_cart_codes', [$this, 'getTaxRates']),
- );
- }
-
- public function getSections()
- {
- return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOnline();
- }
-
- public function getMerchants()
- {
- return $this->merchantStore->getOnline();
- }
-
- public function getReminders($params = [])
- {
- return $this->reminderStore
- ->setMerchant($this->merchantResolver->getCurrent())
- ->setSection($this->sectionResolver->getCurrent())
- ->get($params);
- }
-
- public function getUnits()
- {
- return $this->unitStore->getAsArray();
- }
-
- public function getTaxRates()
- {
- return $this->taxRateStore->setMerchant($this->merchantResolver->getCurrent())->getAsArray();
- }
-
- public function getReductionCartCodes()
- {
- //TODO mettre à jour une fois les repo fait
- return array();
- }
-
-
- }
|