Browse Source

Intégration frontend

packProduct
Guillaume 2 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

@@ -93,18 +93,16 @@ class OrderShopStore extends AbstractStore
// getOrderShopsOfWeek
public function getByCurrentCycle($params = [], $query = null)
{
$orderShops = $this->getBy(
return $this->getBy(
array_merge(
[
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'isValid' => true,
],
$params
),
$query
);

return $orderShops;
}

// getOrderShopsOfWeekByUser
@@ -114,7 +112,7 @@ class OrderShopStore extends AbstractStore
array_merge(
[
'user' => $user,
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'excludeComplementaryOrderShops' => true
],
$params
@@ -202,7 +200,7 @@ class OrderShopStore extends AbstractStore
{
return $this->countBy(
[
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'isValid' => true,
'excludeComplementaryOrderShops' => true
],

+ 4
- 1
Resolver/OpeningResolver.php View File

@@ -109,7 +109,10 @@ class OpeningResolver
// isMaximumOrderWeekAchieved
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);
if ($orderMaximumPerCycle && $countOrderShopCycle >= $orderMaximumPerCycle) {
return true;

+ 8
- 1
Resolver/SectionResolver.php View File

@@ -26,6 +26,13 @@ class SectionResolver
$this->sectionStore = $sectionStore;
}

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

public function getCurrent(): SectionInterface
{
$currentAdminSection = null;
@@ -36,7 +43,6 @@ class SectionResolver
}

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

return $currentAdminSection;
}


+ 17
- 1
Twig/StoreTwigExtension.php View File

@@ -6,6 +6,7 @@ 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\Product\ProductCategoryStore;
use Lc\CaracoleBundle\Repository\Reminder\ReminderStore;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
@@ -26,6 +27,7 @@ class StoreTwigExtension extends AbstractExtension
protected SectionResolver $sectionResolver;
protected UnitStore $unitStore;
protected TaxRateStore $taxRateStore;
protected ProductCategoryStore $productCategoryStore;

public function __construct(
MerchantResolver $merchantResolver,
@@ -34,7 +36,8 @@ class StoreTwigExtension extends AbstractExtension
SectionStore $sectionStore,
ReminderStore $reminderStore,
UnitStore $unitStore,
TaxRateStore $taxRateStore
TaxRateStore $taxRateStore,
ProductCategoryStore $productCategoryStore
) {
$this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver;
@@ -43,25 +46,38 @@ class StoreTwigExtension extends AbstractExtension
$this->reminderStore = $reminderStore;
$this->unitStore = $unitStore;
$this->taxRateStore = $taxRateStore;
$this->productCategoryStore = $productCategoryStore;
}

public function getFunctions()
{
return array(
new TwigFunction('carac_sections', [$this, 'getSections']),
new TwigFunction('carac_section_current', [$this, 'getSectionCurrent']),
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']),
new TwigFunction('carac_product_categories', [$this, 'getProductCategories']),
);
}

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

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

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

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

Loading…
Cancel
Save