use Lc\SovBundle\Translation\FlashBagTranslator; | use Lc\SovBundle\Translation\FlashBagTranslator; | ||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | ||||
use Symfony\Contracts\Cache\CacheInterface; | |||||
use Symfony\Contracts\Cache\ItemInterface; | |||||
use Symfony\Contracts\Cache\TagAwareCacheInterface; | |||||
class OrderShopBuilder | class OrderShopBuilder | ||||
{ | { | ||||
return $orderShop; | return $orderShop; | ||||
} | } | ||||
protected array $cacheCartCurrentBySection = []; | |||||
public function createIfNotExist( | public function createIfNotExist( | ||||
SectionInterface $section, | SectionInterface $section, | ||||
UserInterface $user = null, | UserInterface $user = null, | ||||
VisitorInterface $visitor = null | |||||
VisitorInterface $visitor = null, | |||||
bool $cache = false | |||||
): OrderShopInterface { | ): OrderShopInterface { | ||||
$cart = null; | |||||
// cache | |||||
$cacheIdCartCurrent = 'cart_current_'.$section->getId(); | |||||
if($cache && isset($this->cacheCartCurrentBySection[$cacheIdCartCurrent])) { | |||||
return $this->cacheCartCurrentBySection[$cacheIdCartCurrent]; | |||||
} | |||||
$this->orderShopStore->setSection($section); | $this->orderShopStore->setSection($section); | ||||
$cartUser = $this->orderShopStore->getOneCartCurrent($user); | $cartUser = $this->orderShopStore->getOneCartCurrent($user); | ||||
if ($cartUser && $cartVisitor && $cartUser->getId() != $cartVisitor->getId()) { | if ($cartUser && $cartVisitor && $cartUser->getId() != $cartVisitor->getId()) { | ||||
$cart = $this->merge($cartUser, $cartVisitor); | $cart = $this->merge($cartUser, $cartVisitor); | ||||
} else { | } else { | ||||
$cart = $cartUser ?: $cartVisitor; | |||||
if($cartUser) { | |||||
$cart = $cartUser; | |||||
} | |||||
elseif($cartVisitor) { | |||||
if($user && $cartVisitor && !$cartVisitor->getUser()) { | |||||
$cartVisitor->setUser($user); | |||||
$this->entityManager->update($cartVisitor); | |||||
$this->entityManager->flush(); | |||||
} | |||||
$cart = $cartVisitor; | |||||
} | |||||
} | } | ||||
if (!$cart) { | if (!$cart) { | ||||
// @TODO : obligé de faire ça sinon le panier ne se met pas à jour quand on ajoute des produits. Pourquoi ? | // @TODO : obligé de faire ça sinon le panier ne se met pas à jour quand on ajoute des produits. Pourquoi ? | ||||
$this->entityManager->refresh($cart); | $this->entityManager->refresh($cart); | ||||
// cache | |||||
$this->cacheCartCurrentBySection[$cacheIdCartCurrent] = $cart; | |||||
return $cart; | return $cart; | ||||
} | } | ||||
&& $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery() | && $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery() | ||||
&& (string)$this->priceSolver->getPrice($orderProduct) | && (string)$this->priceSolver->getPrice($orderProduct) | ||||
== (string)$this->priceSolver->getPrice($orderProductAdd) | == (string)$this->priceSolver->getPrice($orderProductAdd) | ||||
&& $orderProduct->getOrderProductReductionCatalog() | |||||
&& $orderProductAdd->getOrderProductReductionCatalog() | |||||
&& $this->orderProductReductionCatalogSolver->compare( | && $this->orderProductReductionCatalogSolver->compare( | ||||
$orderProduct->getOrderProductReductionCatalog(), | $orderProduct->getOrderProductReductionCatalog(), | ||||
$orderProductAdd->getOrderProductReductionCatalog() | $orderProductAdd->getOrderProductReductionCatalog() |
return $this->getOrderShopContainer()->getBuilder()->createIfNotExist( | return $this->getOrderShopContainer()->getBuilder()->createIfNotExist( | ||||
$this->getSectionCurrent(), | $this->getSectionCurrent(), | ||||
$this->getUserCurrent(), | $this->getUserCurrent(), | ||||
$this->getVisitorCurrent() | |||||
$this->getVisitorCurrent(), | |||||
true | |||||
); | ); | ||||
} | } | ||||
$form->handleRequest($request); | $form->handleRequest($request); | ||||
if ($form->isSubmitted() && $form->isValid()) { | if ($form->isSubmitted() && $form->isValid()) { | ||||
$orderShop = $this->getOrderShopContainer()->getBuilder()->createIfNotExist( | $orderShop = $this->getOrderShopContainer()->getBuilder()->createIfNotExist( | ||||
$this->getSectionCurrent(), | $this->getSectionCurrent(), | ||||
$this->getUserCurrent(), | $this->getUserCurrent(), |
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
$fields = parent::configureFields($pageName); | |||||
return array_merge( | |||||
[ | |||||
return [ | |||||
ChoiceField::new('day') | ChoiceField::new('day') | ||||
->setRequired(true) | ->setRequired(true) | ||||
->setChoices( | ->setChoices( | ||||
->setRequired(false) | ->setRequired(false) | ||||
->setFormat('H:mm'), | ->setFormat('H:mm'), | ||||
AssociationField::new('groupUser'), | AssociationField::new('groupUser'), | ||||
], | |||||
$fields | |||||
); | |||||
]; | |||||
} | } | ||||
public function configureCrud(Crud $crud): Crud | public function configureCrud(Crud $crud): Crud |
$idProductFamily = $options['data']['id_product_family']; | $idProductFamily = $options['data']['id_product_family']; | ||||
$productFamily = $this->productFamilyStore->getOneById($idProductFamily); | $productFamily = $this->productFamilyStore->getOneById($idProductFamily); | ||||
// @TODO : obligé sinon ne fonctionne pas. Problème avec le chargement des relations ? | |||||
$this->entityManager->refresh($productFamily); | |||||
$builder->add('id_product_family', HiddenType::class, [ | $builder->add('id_product_family', HiddenType::class, [ | ||||
'data' => $productFamily->getId() | 'data' => $productFamily->getId() | ||||
]); | ]); | ||||
if ($productFamily) { | if ($productFamily) { | ||||
if ($productFamily->getActiveProducts() | if ($productFamily->getActiveProducts() | ||||
&& $productFamily->getBehaviorAddToCart() == 'multiple') { | && $productFamily->getBehaviorAddToCart() == 'multiple') { | ||||
$cpt = 0; | |||||
foreach ($this->productFamilySolver->getProductsGroupByTitle($productFamily) as $key => $product) { | |||||
$cpt = 0; | |||||
foreach ($this->productFamilySolver->getProductsGroupByTitle($productFamily) as $product) { | |||||
$orderProduct = $this->orderProductFactory->create($product[0], 0); | $orderProduct = $this->orderProductFactory->create($product[0], 0); | ||||
$builder->add('order_product_' . $cpt, OrderProductType::class, [ | $builder->add('order_product_' . $cpt, OrderProductType::class, [ | ||||
'data' => $orderProduct | 'data' => $orderProduct | ||||
$product = null; | $product = null; | ||||
if ($productFamily->getActiveProducts()) { | if ($productFamily->getActiveProducts()) { | ||||
$products = $this->productFamilySolver->getProductsOnline($productFamily); | $products = $this->productFamilySolver->getProductsOnline($productFamily); | ||||
if ($products && count($products) > 0) { | if ($products && count($products) > 0) { | ||||
$product = $products[0]; | $product = $products[0]; | ||||
} | } |
// findCartCurrent | // findCartCurrent | ||||
public function getOneCartCurrent(UserInterface $user = null, VisitorInterface $visitor = null, $query = null): ?OrderShopInterface | public function getOneCartCurrent(UserInterface $user = null, VisitorInterface $visitor = null, $query = null): ?OrderShopInterface | ||||
{ | { | ||||
if(is_null($user) && is_null($visitor)) { | |||||
return null; | |||||
} | |||||
$query = $this->createDefaultQuery($query); | $query = $this->createDefaultQuery($query); | ||||
if (!is_null($user)) { | if (!is_null($user)) { |
return $this; | return $this; | ||||
} | } | ||||
public function hasProductFamilyOnline(): self | public function hasProductFamilyOnline(): self | ||||
{ | { | ||||
$this->joinProductFamilies(); | $this->joinProductFamilies(); |
class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
//use SectionRepositoryQueryTrait; | |||||
protected bool $isJoinProductCategories = false; | protected bool $isJoinProductCategories = false; | ||||
protected bool $isJoinProductFamilySectionProperties = false; | protected bool $isJoinProductFamilySectionProperties = false; | ||||
protected bool $isJoinProducts = false; | protected bool $isJoinProducts = false; | ||||
protected bool $isJoinQualityLabels = false; | |||||
public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) | public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function joinQualityLabels(bool $addSelect = true): self | |||||
{ | |||||
if (!$this->isJoinQualityLabels) { | |||||
$this->isJoinQualityLabels = true; | |||||
$this->leftJoin('.qualityLabels', 'pfql'); | |||||
if ($addSelect) { | |||||
$this->addSelect('pfql'); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
public function filterBySection(SectionInterface $section,bool $addSelectProductFamilySectionProperties = true) | public function filterBySection(SectionInterface $section,bool $addSelectProductFamilySectionProperties = true) | ||||
{ | { | ||||
$this->joinProductFamilySectionProperties($addSelectProductFamilySectionProperties); | $this->joinProductFamilySectionProperties($addSelectProductFamilySectionProperties); | ||||
return $this->andWhereEqual('supplier', $supplier); | return $this->andWhereEqual('supplier', $supplier); | ||||
} | } | ||||
public function joinProductCategories(): self | |||||
public function joinProductCategories(bool $addSelect = false): self | |||||
{ | { | ||||
if (!$this->isJoinProductCategories) { | if (!$this->isJoinProductCategories) { | ||||
$this->isJoinProductCategories = true; | $this->isJoinProductCategories = true; | ||||
return $this | return $this | ||||
->leftJoin('.productCategories', 'cat'); | |||||
//$query->addSelect('cat') ; ??? | |||||
->leftJoin('.productCategories', 'cat') | |||||
->addSelect('cat') | |||||
; | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
$this->isJoinProducts = true; | $this->isJoinProducts = true; | ||||
return $this | return $this | ||||
->innerJoin('.products', 'pfp'); | |||||
// $query->addSelect('pfp') ; ????? | |||||
->innerJoin('.products', 'pfp') | |||||
->addSelect('pfp') | |||||
; | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } |
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
if($this->section) { | |||||
$query->filterBySection($this->section); | |||||
} | |||||
if(isset($this->merchant) && $this->merchant) { | |||||
$query->filterByMerchantViaSection($this->merchant); | |||||
} | |||||
$this->addFilterBySectionOptionnal($query); | |||||
$this->addFilterByMerchantViaSectionOptionnal($query); | |||||
return $query; | return $query; | ||||
} | } | ||||
{ | { | ||||
$query->joinProductCategories(); | $query->joinProductCategories(); | ||||
$query->joinProducts(); | $query->joinProducts(); | ||||
$query->joinQualityLabels(); | |||||
return $query; | return $query; | ||||
} | } | ||||
if (($onlyOnDiscount && $productFamily->getReductionCatalog()) || !$onlyOnDiscount) { | if (($onlyOnDiscount && $productFamily->getReductionCatalog()) || !$onlyOnDiscount) { | ||||
if ($organizeByParentCategory) { | if ($organizeByParentCategory) { | ||||
$productCategories = $productFamily->getProductCategories(); | $productCategories = $productFamily->getProductCategories(); | ||||
if ($productCategories && count($productCategories) > 0) { | if ($productCategories && count($productCategories) > 0) { | ||||
$parentCategory = $productCategories[0]->getParentCategory(); | $parentCategory = $productCategories[0]->getParentCategory(); | ||||
if ($this->productCategorySolver->isDisplay($parentCategory, $user)) { | if ($this->productCategorySolver->isDisplay($parentCategory, $user)) { |
$this->isJoinProductFamily = true; | $this->isJoinProductFamily = true; | ||||
return $this | return $this | ||||
->innerJoin('.productFamily', 'pf'); | |||||
//$qb->addSelect('pf'); ??? | |||||
->innerJoin('.productFamily', 'pf') | |||||
->addSelect('pf'); | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } |
protected bool $isJoinProductFamilies = false; | protected bool $isJoinProductFamilies = false; | ||||
protected bool $isJoinProductFamily = false; | protected bool $isJoinProductFamily = false; | ||||
protected bool $isJoinProductCategories = false; | protected bool $isJoinProductCategories = false; | ||||
protected bool $isJoinUsers = false; | |||||
protected bool $isJoinGroupUsers = false; | |||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
public function __construct(ReductionCatalogRepository $repository, PaginatorInterface $paginator) | public function __construct(ReductionCatalogRepository $repository, PaginatorInterface $paginator) | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function joinUsers() | |||||
{ | |||||
if (!$this->isJoinUsers) { | |||||
$this->isJoinUsers = true; | |||||
return $this | |||||
->leftJoin('.users', 'pf_users') | |||||
->addSelect('pf_users') ; | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinGroupUsers() | |||||
{ | |||||
if (!$this->isJoinGroupUsers) { | |||||
$this->isJoinGroupUsers = true; | |||||
return $this | |||||
->leftJoin('.groupUsers', 'pf_groupusers') | |||||
->addSelect('pf_groupusers') ; | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinProductFamilies() | public function joinProductFamilies() | ||||
{ | { | ||||
if (!$this->isJoinProductFamilies) { | if (!$this->isJoinProductFamilies) { | ||||
$this->isJoinProductFamilies = true; | $this->isJoinProductFamilies = true; | ||||
return $this | return $this | ||||
->leftJoin('.productFamilies', 'pfs'); | |||||
//->addSelect('pfs') ; | |||||
->leftJoin('.productFamilies', 'pfs') | |||||
->addSelect('pfs') ; | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
$this->isJoinProductFamily = true; | $this->isJoinProductFamily = true; | ||||
return $this | return $this | ||||
->leftJoin('.productFamily', 'pf'); | |||||
//->addSelect('pf') ; | |||||
->leftJoin('.productFamily', 'pf') | |||||
->addSelect('pf') ; | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
$this->isJoinProductCategories = true; | $this->isJoinProductCategories = true; | ||||
return $this | return $this | ||||
->leftJoin('.productCategories', 'pcs'); | |||||
//->addSelect('pcs') ; | |||||
->leftJoin('.productCategories', 'pcs') | |||||
->addSelect('pcs') ; | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function filterProductFamily(ProductFamilyInterface $productFamily) | public function filterProductFamily(ProductFamilyInterface $productFamily) | ||||
{ | { | ||||
return $this | return $this | ||||
public function filterConditionUser(UserInterface $user = null) | public function filterConditionUser(UserInterface $user = null) | ||||
{ | { | ||||
$this->joinUsers(); | |||||
if ($user) { | if ($user) { | ||||
return $this | return $this | ||||
->andWhere(':user MEMBER OF .users OR .users is empty') | ->andWhere(':user MEMBER OF .users OR .users is empty') | ||||
public function filterConditionGroupUser(UserInterface $user = null) | public function filterConditionGroupUser(UserInterface $user = null) | ||||
{ | { | ||||
$this->joinGroupUsers(); | |||||
if ($user) { | if ($user) { | ||||
return $this | return $this | ||||
->andWhere(':groupUser MEMBER OF .groupUsers OR .groupUsers is empty') | ->andWhere(':groupUser MEMBER OF .groupUsers OR .groupUsers is empty') | ||||
{ | { | ||||
$this->joinProductFamilies(); | $this->joinProductFamilies(); | ||||
$this->joinProductFamily(); | $this->joinProductFamily(); | ||||
return $this | return $this | ||||
->andWhere(':productFamilies MEMBER OF .productFamilies OR .productFamilies is empty') | ->andWhere(':productFamilies MEMBER OF .productFamilies OR .productFamilies is empty') | ||||
->setParameter('productFamilies', $productFamilies); | ->setParameter('productFamilies', $productFamilies); | ||||
{ | { | ||||
$this->joinProductFamilies(); | $this->joinProductFamilies(); | ||||
$this->joinProductFamily(); | $this->joinProductFamily(); | ||||
return $this | return $this | ||||
->andWhere(':productFamily MEMBER OF .productFamilies OR .productFamilies is empty') | ->andWhere(':productFamily MEMBER OF .productFamilies OR .productFamilies is empty') | ||||
->setParameter('productFamily', $productFamily); | ->setParameter('productFamily', $productFamily); | ||||
public function filterConditionProductCategories(array $productCategories) | public function filterConditionProductCategories(array $productCategories) | ||||
{ | { | ||||
$this->joinProductCategories(); | $this->joinProductCategories(); | ||||
return $this | return $this | ||||
->andWhere(':productCategory MEMBER OF .productCategories OR .productCategories is empty') | ->andWhere(':productCategory MEMBER OF .productCategories OR .productCategories is empty') | ||||
->setParameter('productCategory', $productCategories); | ->setParameter('productCategory', $productCategories); |
if (!$this->isOpenSale($section)) { | if (!$this->isOpenSale($section)) { | ||||
$opening = $this->openingSolver->getNextOpeningOfOpening($date, $openingArray); | $opening = $this->openingSolver->getNextOpeningOfOpening($date, $openingArray); | ||||
if ($opening) { | if ($opening) { | ||||
return $this->openingSolver->getFormatedDateByFormatAndDelimiterDayTime( | return $this->openingSolver->getFormatedDateByFormatAndDelimiterDayTime( | ||||
$date, | $date, | ||||
$opening->getTimeStart(), | |||||
$opening->getTimeStart() ?: (new \DateTime())->setTime(0, 0), | |||||
$formatDate, | $formatDate, | ||||
$delimiterDayTime | $delimiterDayTime | ||||
); | ); |
} | } | ||||
} // front | } // front | ||||
else { | else { | ||||
$merchantCurrent = $this->merchantResolver->getCurrent(); | |||||
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent); | |||||
$sectionCurrent = null; | |||||
$sectionDefault = $sectionStore->getOneDefault(); | |||||
if (isset($requestAttributesArray['section'])) { | |||||
$sectionCurrent = $sectionStore | |||||
->setMerchant($merchantCurrent) | |||||
->getOneBySlug($requestAttributesArray['section']); | |||||
if($this->section === null) { | |||||
$merchantCurrent = $this->merchantResolver->getCurrent(); | |||||
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent); | |||||
$sectionCurrent = null; | |||||
$sectionDefault = $sectionStore->getOneDefault(); | |||||
if (isset($requestAttributesArray['section'])) { | |||||
$sectionCurrent = $sectionStore | |||||
->setMerchant($merchantCurrent) | |||||
->getOneBySlug($requestAttributesArray['section']); | |||||
} | |||||
$this->section = $sectionCurrent ?: $sectionDefault; | |||||
} | } | ||||
return $sectionCurrent ?: $sectionDefault; | |||||
return $this->section; | |||||
} | } | ||||
} | } | ||||
// compareOrderProductReductionCatalog | // compareOrderProductReductionCatalog | ||||
public function compare( | public function compare( | ||||
OrderProductReductionCatalogInterface $orderProductReductionCatalog, | |||||
OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare | |||||
OrderProductReductionCatalogInterface $orderProductReductionCatalog = null, | |||||
OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare = null | |||||
): bool { | ): bool { | ||||
if(is_null($orderProductReductionCatalog) && is_null($orderProductReductionCatalogCompare)) { | |||||
return true; | |||||
} | |||||
if(is_null($orderProductReductionCatalog) || is_null($orderProductReductionCatalogCompare)) { | |||||
return false; | |||||
} | |||||
return $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit() | return $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit() | ||||
&& (string)$orderProductReductionCatalog->getValue( | && (string)$orderProductReductionCatalog->getValue( | ||||
) == (string)$orderProductReductionCatalogCompare->getValue() | ) == (string)$orderProductReductionCatalogCompare->getValue() |
|| (($behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY || $behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE) | || (($behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY || $behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE) | ||||
&& $orderProduct->getProduct()->getProductFamily()->getId() == $productFamily->getId())) { | && $orderProduct->getProduct()->getProductFamily()->getId() == $productFamily->getId())) { | ||||
if ($byWeight) { | if ($byWeight) { | ||||
$quantity += $orderProduct->getQuantityOrder() * ($orderProduct->getQuantityProduct() / $orderProduct->getProduct()->getUnitInherited()->getCoefficient()); | |||||
$quantity += $orderProduct->getQuantityOrder() * ($orderProduct->getQuantityProduct() / $this->productSolver->getUnitInherited($orderProduct->getProduct())->getCoefficient()); | |||||
} else { | } else { | ||||
$quantity += $orderProduct->getQuantityOrder(); | $quantity += $orderProduct->getQuantityOrder(); | ||||
} | } |
} | } | ||||
$count = 0; | $count = 0; | ||||
$isClosingDay = false; | |||||
do { | do { | ||||
if ($count) { | if ($count) { | ||||
$date->modify('+1 day'); | $date->modify('+1 day'); | ||||
} | } | ||||
$weekDay = $date->format('N'); | $weekDay = $date->format('N'); | ||||
$isClosingDay = $this->$methodTestDay($weekDay, $openings); | |||||
$testDay = $this->$methodTestDay($weekDay, $openings); | |||||
$count++; | $count++; | ||||
} while (!$isClosingDay && $count <= 7); | |||||
} while (!$testDay && $count <= 8); | |||||
if ($isClosingDay) { | |||||
if ($testDay) { | |||||
return $this->getOpeningByWeekday($weekDay, $openings); | return $this->getOpeningByWeekday($weekDay, $openings); | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
public function isOpeningDay(int $weekDay, array $openings): bool | |||||
protected function isOpeningDay(int $weekDay, array $openings): bool | |||||
{ | { | ||||
return $this->isOpeningOrClosingDay($weekDay, $openings, 'opening'); | |||||
return (bool) $this->getOpeningByWeekday($weekDay, $openings); | |||||
} | } | ||||
public function isClosingDay(int $weekDay, array $openings): bool | |||||
protected function isClosingDay(int $weekDay, array $openings): bool | |||||
{ | { | ||||
return $this->isOpeningOrClosingDay($weekDay, $openings, 'closing'); | |||||
} | |||||
protected function isOpeningOrClosingDay(int $weekDay, array $openings, string $testOpeningOrClosing = 'opening') | |||||
{ | |||||
if ($testOpeningOrClosing == 'opening') { | |||||
$methodGetTime = 'getTimeStart'; | |||||
} else { | |||||
$methodGetTime = 'getTimeEnd'; | |||||
} | |||||
$openingDay = $this->getOpeningByWeekday($weekDay, $openings); | $openingDay = $this->getOpeningByWeekday($weekDay, $openings); | ||||
if ($openingDay && $openingDay->$methodGetTime()) { | |||||
if ($openingDay && $openingDay->getTimeEnd()) { | |||||
return true; | return true; | ||||
} | } | ||||
new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']), | new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']), | ||||
new TwigFunction('section_setting', [$this, 'getSectionSetting']), | new TwigFunction('section_setting', [$this, 'getSectionSetting']), | ||||
new TwigFunction('section_setting_current', [$this, 'getSectionSettingCurrent']), | new TwigFunction('section_setting_current', [$this, 'getSectionSettingCurrent']), | ||||
new TwigFunction('visitor_current', [$this, 'getVisitorCurrent']), | |||||
); | ); | ||||
} | } | ||||
return $this->orderShopBuilder->createIfNotExist( | return $this->orderShopBuilder->createIfNotExist( | ||||
$this->sectionResolver->getCurrent(), | $this->sectionResolver->getCurrent(), | ||||
$this->security->getUser(), | $this->security->getUser(), | ||||
$this->visitorResolver->getCurrent() | |||||
$this->visitorResolver->getCurrent(), | |||||
true | |||||
); | ); | ||||
} | } | ||||
//TODO mettre à jour une fois les repo fait | //TODO mettre à jour une fois les repo fait | ||||
return array(); | return array(); | ||||
} | } | ||||
public function getVisitorCurrent() | |||||
{ | |||||
return $this->visitorResolver->getCurrent(); | |||||
} | |||||
} | } |