Browse Source

Intégration frontend

packProduct
Guillaume 3 years ago
parent
commit
05715d5842
4 changed files with 33 additions and 9 deletions
  1. +4
    -6
      Repository/Order/OrderShopStore.php
  2. +4
    -1
      Resolver/OpeningResolver.php
  3. +8
    -1
      Resolver/SectionResolver.php
  4. +17
    -1
      Twig/StoreTwigExtension.php

+ 4
- 6
Repository/Order/OrderShopStore.php View File

// getOrderShopsOfWeek // getOrderShopsOfWeek
public function getByCurrentCycle($params = [], $query = null) public function getByCurrentCycle($params = [], $query = null)
{ {
$orderShops = $this->getBy(
return $this->getBy(
array_merge( array_merge(
[ [
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'isValid' => true, 'isValid' => true,
], ],
$params $params
), ),
$query $query
); );

return $orderShops;
} }


// getOrderShopsOfWeekByUser // getOrderShopsOfWeekByUser
array_merge( array_merge(
[ [
'user' => $user, 'user' => $user,
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'excludeComplementaryOrderShops' => true 'excludeComplementaryOrderShops' => true
], ],
$params $params
{ {
return $this->countBy( return $this->countBy(
[ [
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'isValid' => true, 'isValid' => true,
'excludeComplementaryOrderShops' => true 'excludeComplementaryOrderShops' => true
], ],

+ 4
- 1
Resolver/OpeningResolver.php View File

// isMaximumOrderWeekAchieved // isMaximumOrderWeekAchieved
public function isMaximumOrderCycleAchieved(SectionInterface $section) public function isMaximumOrderCycleAchieved(SectionInterface $section)
{ {
$countOrderShopCycle = $this->orderShopStore->countValidByCurrentCycle();
$countOrderShopCycle = $this->orderShopStore
->setSection($section)
->countValidByCurrentCycle();

$orderMaximumPerCycle = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_MAXIMUM_PER_CYCLE); $orderMaximumPerCycle = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_MAXIMUM_PER_CYCLE);
if ($orderMaximumPerCycle && $countOrderShopCycle >= $orderMaximumPerCycle) { if ($orderMaximumPerCycle && $countOrderShopCycle >= $orderMaximumPerCycle) {
return true; return true;

+ 8
- 1
Resolver/SectionResolver.php View File

$this->sectionStore = $sectionStore; $this->sectionStore = $sectionStore;
} }


public function getCurrentFrontend()
{
return $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent())
->getOneDefault();
}

public function getCurrent(): SectionInterface public function getCurrent(): SectionInterface
{ {
$currentAdminSection = null; $currentAdminSection = null;
} }


if ($currentAdminSection === null) { if ($currentAdminSection === null) {
$currentAdminSection = $this->em->getRepository(SectionInterface::class)->findOneBy(array('isDefault' => true));
$currentAdminSection = $this->sectionStore $currentAdminSection = $this->sectionStore
->setMerchant($userMerchant->getMerchant()) ->setMerchant($userMerchant->getMerchant())
->getOneDefault(); ->getOneDefault();
throw new \ErrorException('Aucune section par défaut définie pour ce merchant'); throw new \ErrorException('Aucune section par défaut définie pour ce merchant');
} }
} }

return $currentAdminSection; return $currentAdminSection;
} }



+ 17
- 1
Twig/StoreTwigExtension.php View File

use Lc\CaracoleBundle\Repository\Config\UnitStore; use Lc\CaracoleBundle\Repository\Config\UnitStore;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery; use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore;
use Lc\CaracoleBundle\Repository\Reminder\ReminderStore; use Lc\CaracoleBundle\Repository\Reminder\ReminderStore;
use Lc\CaracoleBundle\Repository\Section\SectionRepository; use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface; use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
protected SectionResolver $sectionResolver; protected SectionResolver $sectionResolver;
protected UnitStore $unitStore; protected UnitStore $unitStore;
protected TaxRateStore $taxRateStore; protected TaxRateStore $taxRateStore;
protected ProductCategoryStore $productCategoryStore;


public function __construct( public function __construct(
MerchantResolver $merchantResolver, MerchantResolver $merchantResolver,
SectionStore $sectionStore, SectionStore $sectionStore,
ReminderStore $reminderStore, ReminderStore $reminderStore,
UnitStore $unitStore, UnitStore $unitStore,
TaxRateStore $taxRateStore
TaxRateStore $taxRateStore,
ProductCategoryStore $productCategoryStore
) { ) {
$this->merchantResolver = $merchantResolver; $this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver; $this->sectionResolver = $sectionResolver;
$this->reminderStore = $reminderStore; $this->reminderStore = $reminderStore;
$this->unitStore = $unitStore; $this->unitStore = $unitStore;
$this->taxRateStore = $taxRateStore; $this->taxRateStore = $taxRateStore;
$this->productCategoryStore = $productCategoryStore;
} }


public function getFunctions() public function getFunctions()
{ {
return array( return array(
new TwigFunction('carac_sections', [$this, 'getSections']), new TwigFunction('carac_sections', [$this, 'getSections']),
new TwigFunction('carac_section_current', [$this, 'getSectionCurrent']),
new TwigFunction('carac_merchants', [$this, 'getMerchants']), new TwigFunction('carac_merchants', [$this, 'getMerchants']),
new TwigFunction('carac_reminders', [$this, 'getReminders']), new TwigFunction('carac_reminders', [$this, 'getReminders']),
new TwigFunction('carac_units', [$this, 'getUnits']), new TwigFunction('carac_units', [$this, 'getUnits']),
new TwigFunction('carac_tax_rates', [$this, 'getTaxRates']), new TwigFunction('carac_tax_rates', [$this, 'getTaxRates']),
new TwigFunction('carac_reduction_cart_codes', [$this, 'getTaxRates']), new TwigFunction('carac_reduction_cart_codes', [$this, 'getTaxRates']),
new TwigFunction('carac_product_categories', [$this, 'getProductCategories']),
); );
} }


public function getProductCategories()
{
return $this->productCategoryStore->getParent(false);
}

public function getSections() public function getSections()
{ {
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOnline(); return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOnline();
} }


public function getSectionCurrent()
{
return $this->sectionResolver->getCurrentFrontend();
}

public function getMerchants() public function getMerchants()
{ {
return $this->merchantStore->getOnline(); return $this->merchantStore->getOnline();

Loading…
Cancel
Save