Browse Source

Refactoring frontend

packProduct
Guillaume 3 years ago
parent
commit
565388d484
12 changed files with 336 additions and 80 deletions
  1. +3
    -0
      Builder/User/UserMerchantBuilder.php
  2. +5
    -0
      Container/Merchant/MerchantContainer.php
  3. +9
    -3
      Controller/ControllerTrait.php
  4. +101
    -0
      Controller/Product/FavoriteController.php
  5. +1
    -1
      Repository/Order/OrderShopStore.php
  6. +12
    -4
      Repository/Product/ProductFamilyRepositoryQuery.php
  7. +116
    -9
      Repository/Product/ProductFamilyStore.php
  8. +62
    -1
      Solver/Order/OrderShopSolver.php
  9. +3
    -3
      Solver/Price/PriceSolver.php
  10. +9
    -0
      Solver/Product/ProductFamilySolver.php
  11. +2
    -58
      Solver/Product/ProductSolver.php
  12. +13
    -1
      Twig/StoreTwigExtension.php

+ 3
- 0
Builder/User/UserMerchantBuilder.php View File

if (!$userMerchant) { if (!$userMerchant) {
$userMerchantFactory = new UserMerchantFactory(); $userMerchantFactory = new UserMerchantFactory();
$userMerchant = $userMerchantFactory->create($user, $merchant); $userMerchant = $userMerchantFactory->create($user, $merchant);

$this->entityManager->create($userMerchant);
$this->entityManager->flush();
} }


return $userMerchant; return $userMerchant;

+ 5
- 0
Container/Merchant/MerchantContainer.php View File

{ {
return $this->store; return $this->store;
} }

public function getBuilder(): MerchantBuilder
{
return $this->builder;
}
} }

+ 9
- 3
Controller/ControllerTrait.php View File

use Lc\CaracoleBundle\Model\User\VisitorInterface; use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver; use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver; use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\CaracoleBundle\Resolver\VisitorResolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver; use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;


public function getMerchantSettingCurrent($settingName) public function getMerchantSettingCurrent($settingName)
{ {
return $this->getSettingValue($this->getCurrentMerchant(), $settingName);
return $this->getSettingValue($this->getMerchantCurrent(), $settingName);
} }


public function getSectionSettingCurrent($settingName) public function getSectionSettingCurrent($settingName)


public function getVisitorCurrent(): VisitorInterface public function getVisitorCurrent(): VisitorInterface
{ {
return $this->get(VisitorResolver::class)->getCurrent();
} }


public function getMerchantCurrent(): MerchantInterface public function getMerchantCurrent(): MerchantInterface


public function getUserMerchantCurrent(): UserMerchantInterface public function getUserMerchantCurrent(): UserMerchantInterface
{ {
return $this->getUserMerchantContainer()->getBuilder()->createIfNotExist($this->getCurrentUser(), $this->getCurrentMerchant());
return $this->getUserMerchantContainer()->getBuilder()->createIfNotExist($this->getUserCurrent(), $this->getMerchantCurrent());
}

public function getMerchantUserCurrent(): MerchantInterface
{
return $this->get(MerchantResolver::class)->getMerchantUser($this->getUserCurrent());
} }


public function getSectionCurrent(): SectionInterface public function getSectionCurrent(): SectionInterface

+ 101
- 0
Controller/Product/FavoriteController.php View File

<?php

namespace Lc\CaracoleBundle\Controller\Product;

use Lc\CaracoleBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class FavoriteController extends AbstractController
{
/**
* @Route("/favorite/toggle", name="lc_frontend_favorite_toggle")
*/
public function toggle(Request $request)
{
$user = $this->_getUser();
$productFamily = $this->_getProductFamily($request);

if ($user->getFavoriteProductFamilies()->contains($productFamily)) {
$user->removeFavoriteProductFamily($productFamily);
$isFavorite = false;
$message = 'Le produit a bien été supprimé de vos favoris';
} else {
$user->addFavoriteProductFamily($productFamily);
$isFavorite = true;
$message = 'Le produit a bien été ajouté à vos favoris';
}

$this->_saveUser($user);

return new JsonResponse([
'return' => 'success',
'is_favorite' => $isFavorite,
'message' => $message
]);
}

/**
* @Route("/favorite/add", name="lc_frontend_favorite_add")
*/
public function add(Request $request)
{
$user = $this->_getUser();
$productFamily = $this->_getProductFamily($request);

$user->addFavoriteProductFamily($productFamily);
$this->_saveUser($user);

return new JsonResponse([
'return' => 'success',
'message' => 'Le produit a bien été ajouté à vos favoris'
]);
}

/**
* @Route("/favorite/delete", name="lc_frontend_favorite_delete")
*/
public function delete(Request $request)
{
$user = $this->_getUser();
$productFamily = $this->_getProductFamily($request);

$user->removeFavoriteProductFamily($productFamily);
$this->_saveUser($user);

return new JsonResponse([
'return' => 'success',
'message' => 'Le produit a bien été supprimé de vos favoris'
]);
}

private function _getUser()
{
$user = $this->getUserCurrent();
if (!$user) {
throw new \ErrorException('Vous devez être connecté pour gérer vos favoris');
}

return $user;
}

private function _saveUser($user)
{
$entityManager = $this->getEntityManager();
$entityManager->persist($user);
$entityManager->flush();
}

private function _getProductFamily($request)
{
$idProductFamily = $request->request->get('idProductFamily');
$productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily);

if ($productFamily) {
return $productFamily;
} else {
throw new \ErrorException('Ce produit est introuvable');
}
}
}

+ 1
- 1
Repository/Order/OrderShopStore.php View File

} }


// findCartCurrent // findCartCurrent
public function getOneCartCurrent(array $params, $query = null): ?OrderShopInterface
public function getOneCartCurrent(array $params = [], $query = null): ?OrderShopInterface
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);



+ 12
- 4
Repository/Product/ProductFamilyRepositoryQuery.php View File



use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery; use Lc\SovBundle\Repository\AbstractRepositoryQuery;


class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
{ {
protected bool $isJoinProductCategories;
protected bool $isJoinProducts;
use SectionRepositoryQueryTrait;

protected bool $isJoinProductCategories = false;
protected bool $isJoinProducts = false;


public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator)
{ {
$dateTime = new \DateTime(); $dateTime = new \DateTime();
} }


return $this->andWhere(':now <= e.propertyNoveltyExpirationDate')
return $this->andWhere(':now <= .propertyNoveltyExpirationDate')
->setParameter('now', $dateTime); ->setParameter('now', $dateTime);
} }




public function filterIsNovelty() public function filterIsNovelty()
{ {
return $this->andWhere(':now <= e.propertyNoveltyExpirationDate')
return $this->andWhere(':now <= .propertyNoveltyExpirationDate')
->setParameter('now', new \DateTime()) ; ->setParameter('now', new \DateTime()) ;
} }


return $this; return $this;
} }


public function filterBySupplier($supplier): self
{
return $this->andWhereEqual('supplier', $supplier);
}

public function joinProductCategories(): self public function joinProductCategories(): self
{ {
if (!$this->isJoinProductCategories) { if (!$this->isJoinProductCategories) {

+ 116
- 9
Repository/Product/ProductFamilyStore.php View File

use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait; use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Solver\Price\PriceSolver; use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractStore; use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;


public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{ {
$query->orderBy('position'); $query->orderBy('position');
return $query;
} }


public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
} }


// getProductFamiliesNovelties // getProductFamiliesNovelties
public function getNovelty($query = null)
public function getNovelty($user = null, $organizeByParentCategory = true, $query = null)
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);


->filterByPropertyNoveltyExpirationDate() ->filterByPropertyNoveltyExpirationDate()
->filterIsOnline(); ->filterIsOnline();


return $query->find();
$results = $query->find();

return $this->getWithReductions($results, $user, false, $organizeByParentCategory);
} }


// getProductFamiliesOrganics // getProductFamiliesOrganics
public function getOrganic($query = null)
public function getOrganic($user = null, $organizeByParentCategory = true, $query = null)
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);


->filterPropertyOrganicLabel() ->filterPropertyOrganicLabel()
->filterIsOnline(); ->filterIsOnline();


return $query->find();
$results = $query->find();

return $this->getWithReductions($results, $user, false, $organizeByParentCategory);
} }


// getProductFamiliesOnDiscount // getProductFamiliesOnDiscount
public function getDiscount($organizeByParentCategory = false, $user = null, $query = null)
public function getDiscount($user = null, $organizeByParentCategory = true, $query = null)
{ {
return $this->getWithReductions($this->getOnline($query), $user, $organizeByParentCategory, true);
return $this->getWithReductions($this->getOnline($query), $user, false, $organizeByParentCategory);
} }


// getProductFamiliesFavorites // getProductFamiliesFavorites
public function getFavorite($user = null)
public function getFavorite($user = null, $organizeByParentCategory = true, $query = null)
{ {
if ($user) { if ($user) {
return $this->getWithReductions($user->getProductFamiliesFavorites(), $user, false, true);
return $this->getWithReductions($user->getProductFamiliesFavorites(), $user, false, $organizeByParentCategory);
} }


return []; return [];
} }


//findByTerms
// findByTerms
public function getByTerms($terms, $maxResults = false, $query = null) public function getByTerms($terms, $maxResults = false, $query = null)
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);
} }
} }


// setReductionForProductFamilies
public function getWithReductions(
array $productFamilies,
UserInterface $user = null,
$organizeByCategory = false,
$organizeByParentCategory = false,
$onlyOnDiscount = false
) {
$conditions = [
'ids' => [],
'categories' => [],
];
foreach ($productFamilies as $productFamily) {
$conditions['ids'][] = $productFamily->getId();
$conditions['categories'] = array_merge(
$conditions['categories'],
$productFamily->getProductCategories()->toArray()
);
}

if ($productFamilies) {
$reductionCatalogs = $this->reductionCatalogStore->getByProductFamilies(
$conditions,
$user
);
}

$productFamiliesToReturn = array();
foreach ($productFamilies as $productFamily) {
foreach ($reductionCatalogs as $reductionCatalog) {
$conditionProductFamilies = $conditionProductFamily = $conditionProductCategory = false;

if ($reductionCatalog->getProductFamilies()->contains(
$productFamily
) || $reductionCatalog->getProductFamilies()->isEmpty()) {
$conditionProductFamilies = true;
}

if ($reductionCatalog->getProductFamily() == $productFamily || $reductionCatalog->getProductFamily(
) === null) {
$conditionProductFamily = true;
}

foreach ($productFamily->getProductCategories() as $productCategory) {
if ($reductionCatalog->getProductCategories()->contains(
$productCategory
) || $reductionCatalog->getProductCategories()->isEmpty()) {
$conditionProductCategory = true;
}
}

if ($conditionProductFamilies && $conditionProductFamily && $conditionProductCategory) {
if ($productFamily->getReductionCatalog()) {
$productFamily->setReductionCatalog(
$this->getBestReductionCatalog(
$productFamily,
$reductionCatalog,
$productFamily->getReductionCatalog()
)
);
} else {
$productFamily->setReductionCatalog($reductionCatalog);
}
}
}

if (($onlyOnDiscount && $productFamily->getReductionCatalog()) || !$onlyOnDiscount) {
if ($organizeByParentCategory) {
$productCategories = $productFamily->getProductCategories();
if ($productCategories && count($productCategories) > 0) {
$parentCategory = $productCategories[0]->getParentCategory();
if ($this->productCategorySolver->isDisplay($parentCategory, $user)) {
if (!isset($productFamiliesToReturn[$parentCategory->getId()])) {
$productFamiliesToReturn[$parentCategory->getId()] = [
'category' => $parentCategory,
'products' => []
];
}
$productFamiliesToReturn[$parentCategory->getId()]['products'][] = $productFamily;
}
}
} elseif ($organizeByCategory) {
foreach ($productFamily->getProductCategories() as $productCategory) {
if ($this->isDisplay($productFamily)) {
$productFamiliesToReturn[$productCategory->getId()][] = $productFamily;
}
}
} else {
if ($this->isDisplay($productFamily)) {
$productFamiliesToReturn[] = $productFamily;
}
}
}
}

if ($organizeByParentCategory) {
uasort($productFamiliesToReturn, array($this, 'compMethodSortProductFamiliesByParentCategory'));
}

return $productFamiliesToReturn;
}


} }

+ 62
- 1
Solver/Order/OrderShopSolver.php View File

use Lc\CaracoleBundle\Model\Product\ProductInterface; use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Solver\Price\PriceSolver; use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Product\ProductSolver;


class OrderShopSolver class OrderShopSolver
{ {
protected PriceSolver $priceSolver; protected PriceSolver $priceSolver;
protected EntityManagerInterface $entityManager; protected EntityManagerInterface $entityManager;
protected ProductSolver $productSolver;


public function __construct(PriceSolver $priceSolver, EntityManagerInterface $entityManager)
public function __construct(PriceSolver $priceSolver, EntityManagerInterface $entityManager, ProductSolver $productSolver)
{ {
$this->priceSolver = $priceSolver; $this->priceSolver = $priceSolver;
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->productSolver = $productSolver;
} }


public function countQuantities(OrderShopInterface $orderShop): int public function countQuantities(OrderShopInterface $orderShop): int
return $quantity; return $quantity;
} }


// isProductAvailable
public function isAvailable(ProductInterface $product, $quantityOrder = 0, $checkCart = false, $orderShop = null)
{
if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus() != 1 || !$this->productSolver->isProductSaleStatusOn($product)) {
return false;
}

// @TODO : orderShop à définir où est appelé isAvailable
if ($checkCart && !$orderShop) {
throw new \Exception("Attention : définir le orderShop à l'endroit où est appelé isAvailable");
}

$productFamily = $product->getProductFamily();
$quantityAsked = $quantityOrder;

if ($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE) {
if (!$quantityOrder) {
$quantityAsked = $this->getQuantityOrderByProduct($orderShop, $product, true);
} else {
$quantityAsked = ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient()) * $quantityOrder;
}

if ($checkCart) {
$quantityAsked += $this->getQuantityOrderByProduct($orderShop, $product, true);
}
}

if (($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT)) {

if (!$quantityOrder) {
$quantityAsked = $this->getQuantityOrderByProduct($orderShop, $product);
}

if ($checkCart) {
$quantityAsked += $this->getQuantityOrderByProduct($orderShop, $product);
}
}

if ($product->getAvailableQuantityInherited() >= $quantityAsked
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_UNLIMITED) {
return true;
} else {
return false;
}
}

public function isOneProductAvailableAddCart(OrderShopInterface $orderShop, $products): bool
{
foreach ($products as $product) {
if ($this->isAvailable($product, 1, true, $orderShop)) {
return true;
}
}

return false;
}

public function getTotalOrderPayments(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): float public function getTotalOrderPayments(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): float
{ {
$totalAmount = floatval(0); $totalAmount = floatval(0);

+ 3
- 3
Solver/Price/PriceSolver.php View File

$service = ''; $service = '';


if ($entity instanceof ProductPropertyInterface) { if ($entity instanceof ProductPropertyInterface) {
$service = 'productPriceResolver';
$service = 'productPriceSolver';
} }


if ($entity instanceof OrderProductInterface) { if ($entity instanceof OrderProductInterface) {
$service = 'orderProductPriceResolver';
$service = 'orderProductPriceSolver';
} }


if ($entity instanceof OrderShopInterface || is_iterable($entity) || is_array($entity)) { if ($entity instanceof OrderShopInterface || is_iterable($entity) || is_array($entity)) {
$service = 'orderShopPriceResolver';
$service = 'orderShopPriceSolver';
} }


if (strlen($service) && $entity && method_exists($this->$service, $name)) { if (strlen($service) && $entity && method_exists($this->$service, $name)) {

+ 9
- 0
Solver/Product/ProductFamilySolver.php View File

return false; return false;
} }
} }

public function countProductFamiliesOrganizedByParentCategory(array $categories): int
{
$count = 0;
foreach ($categories as $category) {
$count += count($category['products']);
}
return $count;
}
} }





+ 2
- 58
Solver/Product/ProductSolver.php View File



namespace Lc\CaracoleBundle\Solver\Product; namespace Lc\CaracoleBundle\Solver\Product;


use Doctrine\Common\Collections\ArrayCollection;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface; use Lc\CaracoleBundle\Model\Product\ProductInterface;


class ProductSolver class ProductSolver
{ {


// isProductAvailable
public function isAvailable(ProductInterface $product, $quantityOrder = 0, $checkCart = false, $orderShop = null)
{
if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus() != 1 || !$this->isProductSaleStatusOn($product)) {
return false;
}

// @TODO : orderShop à définir où est appelé isProductAvailable
if ($checkCart && !$orderShop) {
throw new \Exception("Attention jeune padawan : définir le orderShop à l'endroit où est appelé isProductAvailable");
}

$productFamily = $product->getProductFamily();
$quantityAsked = $quantityOrder;

if ($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE) {
if (!$quantityOrder) {
$quantityAsked = $orderShop->getQuantityOrderByProduct($product, true);
} else {
$quantityAsked = ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient()) * $quantityOrder;
}

if ($checkCart) {
$quantityAsked += $orderShop->getQuantityOrderByProduct($product, true);
}
}

if (($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT)) {

if (!$quantityOrder) {
$quantityAsked = $orderShop->getQuantityOrderByProduct($product);
}

if ($checkCart) {
$quantityAsked += $orderShop->getQuantityOrderByProduct($product);
}
}

if ($product->getAvailableQuantityInherited() >= $quantityAsked
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_UNLIMITED) {
return true;
} else {
return false;
}
}

public function isOneProductAvailableAddCart(array $products): bool
{
foreach ($products as $product) {
if ($product->isAvailable(1, true)) {
return true;
}
}

return false;
}

public function isProductSaleStatusOn(ProductInterface $product) public function isProductSaleStatusOn(ProductInterface $product)
{ {
if ($product->getProductFamily()->getSaleStatus() != 1) { if ($product->getProductFamily()->getSaleStatus() != 1) {

+ 13
- 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\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore; 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;
protected UnitStore $unitStore; protected UnitStore $unitStore;
protected TaxRateStore $taxRateStore; protected TaxRateStore $taxRateStore;
protected ProductCategoryStore $productCategoryStore; protected ProductCategoryStore $productCategoryStore;
protected OrderShopStore $orderShopStore;


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


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_section_current', [$this, 'getSectionCurrent']),
new TwigFunction('carac_cart_current', [$this, 'getCartCurrent']),
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']),
return $this->sectionResolver->getCurrent(); return $this->sectionResolver->getCurrent();
} }


public function getCartCurrent()
{
return $this->orderShopStore
->setSection($this->sectionResolver->getCurrent())
->getOneCartCurrent();
}

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

Loading…
Cancel
Save