소스 검색

Refactoring frontend

packProduct
Guillaume 2 년 전
부모
커밋
f55e805fa4
15개의 변경된 파일164개의 추가작업 그리고 42개의 파일을 삭제
  1. +9
    -0
      Container/Address/AddressContainer.php
  2. +9
    -0
      Container/Product/ProductFamilyContainer.php
  3. +28
    -1
      Container/User/VisitorContainer.php
  4. +0
    -3
      Model/User/UserModel.php
  5. +2
    -1
      Model/User/VisitorModel.php
  6. +4
    -4
      Repository/Product/ProductFamilyStore.php
  7. +11
    -11
      Repository/Reduction/ReductionCatalogRepositoryQuery.php
  8. +1
    -1
      Repository/User/VisitorRepositoryQuery.php
  9. +1
    -1
      Repository/User/VisitorStore.php
  10. +5
    -1
      Resolver/MerchantResolver.php
  11. +9
    -1
      Resolver/OpeningResolver.php
  12. +2
    -2
      Resources/views/adminlte/layout.html.twig
  13. +2
    -2
      Solver/Order/OrderShopSolver.php
  14. +21
    -0
      Solver/User/VisitorSolver.php
  15. +60
    -14
      Twig/StoreTwigExtension.php

+ 9
- 0
Container/Address/AddressContainer.php 파일 보기

@@ -6,21 +6,25 @@ use Lc\CaracoleBundle\Builder\Address\AddressBuilder;
use Lc\CaracoleBundle\Factory\Address\AddressFactory;
use Lc\CaracoleBundle\Repository\Address\AddressRepositoryQuery;
use Lc\CaracoleBundle\Repository\Address\AddressStore;
use Lc\CaracoleBundle\Solver\Address\AddressSolver;

class AddressContainer
{
protected AddressFactory $factory;
protected AddressSolver $solver;
protected AddressRepositoryQuery $repositoryQuery;
protected AddressStore $store;
protected AddressBuilder $builder;

public function __construct(
AddressFactory $factory,
AddressSolver $solver,
AddressRepositoryQuery $repositoryQuery,
AddressStore $store,
AddressBuilder $builder
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->builder = $builder;
@@ -31,6 +35,11 @@ class AddressContainer
return $this->factory;
}

public function getSolver(): AddressSolver
{
return $this->solver;
}

public function getRepositoryQuery(): AddressRepositoryQuery
{
return $this->repositoryQuery;

+ 9
- 0
Container/Product/ProductFamilyContainer.php 파일 보기

@@ -5,19 +5,23 @@ namespace Lc\CaracoleBundle\Container\Product;
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver;

class ProductFamilyContainer
{
protected ProductFamilyFactory $factory;
protected ProductFamilySolver $solver;
protected ProductFamilyRepositoryQuery $repositoryQuery;
protected ProductFamilyStore $store;

public function __construct(
ProductFamilyFactory $factory,
ProductFamilySolver $solver,
ProductFamilyRepositoryQuery $repositoryQuery,
ProductFamilyStore $store
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}
@@ -27,6 +31,11 @@ class ProductFamilyContainer
return $this->factory;
}

public function getSolver(): ProductFamilySolver
{
return $this->solver;
}

public function getRepositoryQuery(): ProductFamilyRepositoryQuery
{
return $this->repositoryQuery;

+ 28
- 1
Container/User/VisitorContainer.php 파일 보기

@@ -2,24 +2,36 @@

namespace Lc\CaracoleBundle\Container\User;

use Lc\CaracoleBundle\Builder\User\VisitorBuilder;
use Lc\CaracoleBundle\Factory\User\VisitorFactory;
use Lc\CaracoleBundle\Repository\User\VisitorRepositoryQuery;
use Lc\CaracoleBundle\Repository\User\VisitorStore;
use Lc\CaracoleBundle\Resolver\VisitorResolver;
use Lc\CaracoleBundle\Solver\User\VisitorSolver;

class VisitorContainer
{
protected VisitorFactory $factory;
protected VisitorSolver $solver;
protected VisitorRepositoryQuery $repositoryQuery;
protected VisitorStore $store;
protected VisitorResolver $resolver;
protected VisitorBuilder $visitorBuilder;

public function __construct(
VisitorFactory $factory,
VisitorSolver $solver,
VisitorRepositoryQuery $repositoryQuery,
VisitorStore $store
VisitorStore $store,
VisitorResolver $resolver,
VisitorBuilder $builder
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->resolver = $resolver;
$this->builder = $builder;
}

public function getFactory(): VisitorFactory
@@ -27,6 +39,11 @@ class VisitorContainer
return $this->factory;
}

public function getSolver(): VisitorSolver
{
return $this->solver;
}

public function getRepositoryQuery(): VisitorRepositoryQuery
{
return $this->repositoryQuery;
@@ -37,4 +54,14 @@ class VisitorContainer
return $this->store;
}

public function getResolver(): VisitorResolver
{
return $this->resolver;
}

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

}

+ 0
- 3
Model/User/UserModel.php 파일 보기

@@ -5,16 +5,13 @@ namespace Lc\CaracoleBundle\Model\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\SovBundle\Model\User\UserModel as SovUserModel;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;

/**
* @ORM\MappedSuperclass()

+ 2
- 1
Model/User/VisitorModel.php 파일 보기

@@ -6,11 +6,12 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\SovBundle\Doctrine\EntityInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class VisitorModel
abstract class VisitorModel implements EntityInterface
{
/**
* @ORM\Column(type="string", length=255)

+ 4
- 4
Repository/Product/ProductFamilyStore.php 파일 보기

@@ -76,7 +76,7 @@ class ProductFamilyStore extends AbstractStore
$query = $this->createDefaultQuery($query);

$query
->filterPropertyOrganicLabel()
->filterIsOrganicLabel()
->filterIsOnline();

$results = $query->find();
@@ -94,7 +94,7 @@ class ProductFamilyStore extends AbstractStore
public function getFavorite($user = null, $organizeByParentCategory = true, $query = null)
{
if ($user) {
return $this->getWithReductions($user->getProductFamiliesFavorites(), $user, false, $organizeByParentCategory);
return $this->getWithReductions($user->getFavoriteProductFamilies(), $user, false, $organizeByParentCategory);
}

return [];
@@ -145,7 +145,7 @@ class ProductFamilyStore extends AbstractStore

// setReductionForProductFamilies
public function getWithReductions(
array $productFamilies,
$productFamilies,
UserInterface $user = null,
$organizeByCategory = false,
$organizeByParentCategory = false,
@@ -164,7 +164,7 @@ class ProductFamilyStore extends AbstractStore
}

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

+ 11
- 11
Repository/Reduction/ReductionCatalogRepositoryQuery.php 파일 보기

@@ -11,9 +11,9 @@ use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
{
protected bool $isJoinProductFamilies;
protected bool $isJoinProductFamily;
protected bool $isJoinProductCategories;
protected bool $isJoinProductFamilies = false;
protected bool $isJoinProductFamily = false;
protected bool $isJoinProductCategories = false;
use SectionRepositoryQueryTrait;

public function __construct(ReductionCatalogRepository $repository, PaginatorInterface $paginator)
@@ -68,7 +68,7 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
public function filterConditionDate()
{
return $this
->andWhere('e.permanent = 1 OR (e.dateStart <= :now AND e.dateEnd >= :now)')
->andWhere('.permanent = 1 OR ( .dateStart <= :now AND .dateEnd >= :now)')
->setParameter(':now', new \DateTime());
}

@@ -76,11 +76,11 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
{
if ($user) {
return $this
->andWhere(':user MEMBER OF e.users OR e.users is empty')
->andWhere(':user MEMBER OF .users OR .users is empty')
->setParameter('user', $user);
} else {
return $this
->andWhere('e.users is empty');
->andWhere('.users is empty');
}
}

@@ -88,11 +88,11 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
{
if ($user) {
return $this
->andWhere(':groupUser MEMBER OF e.groupUsers OR e.groupUsers is empty')
->andWhere(':groupUser MEMBER OF .groupUsers OR .groupUsers is empty')
->setParameter('groupUser', $user->getGroupUsers());
} else {
return $this
->andWhere('e.groupUsers is empty');
->andWhere('.groupUsers is empty');
}
}

@@ -101,7 +101,7 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
$this->joinProductFamilies();
$this->joinProductFamily();
return $this
->andWhere(':productFamilies MEMBER OF e.productFamilies OR e.productFamilies is empty')
->andWhere(':productFamilies MEMBER OF .productFamilies OR .productFamilies is empty')
->setParameter('productFamilies', $productFamilies);
}

@@ -110,7 +110,7 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
$this->joinProductFamilies();
$this->joinProductFamily();
return $this
->andWhere(':productFamily MEMBER OF e.productFamilies OR e.productFamilies is empty')
->andWhere(':productFamily MEMBER OF .productFamilies OR .productFamilies is empty')
->setParameter('productFamily', $productFamily);
}

@@ -118,7 +118,7 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
{
$this->joinProductCategories();
return $this
->andWhere(':productCategory MEMBER OF e.productCategories OR e.productCategories is empty')
->andWhere(':productCategory MEMBER OF .productCategories OR .productCategories is empty')
->setParameter('productCategory', $productCategories);
}


+ 1
- 1
Repository/User/VisitorRepositoryQuery.php 파일 보기

@@ -12,7 +12,7 @@ class VisitorRepositoryQuery extends AbstractRepositoryQuery
parent::__construct($repository, 'r', $paginator);
}

public function filterByCookie(string $cookie)
public function filterByCookie(string $cookie = null)
{
return $this
->andWhere('.cookie LIKE :cookie')

+ 1
- 1
Repository/User/VisitorStore.php 파일 보기

@@ -30,7 +30,7 @@ class VisitorStore extends AbstractStore
return $query;
}

public function getOneByCookie(string $cookie, $query = null)
public function getOneByCookie(string $cookie = null, $query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByCookie($cookie);

+ 5
- 1
Resolver/MerchantResolver.php 파일 보기

@@ -130,10 +130,14 @@ class MerchantResolver

public function getMerchantUser(UserInterface $user = null)
{
if(is_null($user)) {
$user = $this->security->getUser();
}

$merchants = $this->merchantStore->getOnline();

if ($user) {
return $user->getMerchant();
return $user->getFavoriteMerchant();
} else {
$merchantCurrentId = $this->requestStack->getCurrentRequest()->cookies->getInt(
$this->parameterBag->get('app.cookie_name_merchant_current')

+ 9
- 1
Resolver/OpeningResolver.php 파일 보기

@@ -213,8 +213,16 @@ class OpeningResolver
$this->messages[] = $message;
}

public function isOpenSaleOnlyComplementaryOrders(Section $section, UserInterface $user)
public function isOpenSaleOnlyComplementaryOrders(Section $section = null, UserInterface $user = null)
{
if(is_null($section)) {
$section = $this->sectionResolver->getCurrent();
}

if(is_null($user)) {
$user = $this->security->getUser();
}

// @TODO : ajouter une option dans les sections (permettre les commandes complémentaires ou non)
$orderShopsUser = $this->orderShopStore->setSection($section)->getByCurrentCycleAndUser($user);


+ 2
- 2
Resources/views/adminlte/layout.html.twig 파일 보기

@@ -3,7 +3,7 @@
{% block navbar_header %}
{{ parent() }}

{% set section_current = section_resolver.getCurrent() %}
{% set section_current = section_current() %}
{% set is_display_switch_section = display_switch_section is defined and display_switch_section %}

<nav class="carac navbar navbar-expand navbar-light main-header{% if is_display_switch_section %} display-section-switch{% endif %}" {% if is_display_switch_section %}style="border-color: {{ section_current.color }};"{% endif %}>
@@ -43,7 +43,7 @@
{% block append_body %}
{# modal switch merchant #}
{% set user = app.user %}
{% set merchant_current = merchant_resolver.getCurrent() %}
{% set merchant_current = merchant_current() %}

{% if(user.favoriteMerchant != merchant_current) %}
{# modal affichée uniquement si la sessionStorage.visit_merchant n'est pas défini (js) #}

+ 2
- 2
Solver/Order/OrderShopSolver.php 파일 보기

@@ -105,7 +105,7 @@ class OrderShopSolver
}

// isProductAvailable
public function isAvailable(ProductInterface $product, $quantityOrder = 0, $checkCart = false, $orderShop = null)
public function isProductAvailable(ProductInterface $product, $quantityOrder = 0, $checkCart = false, $orderShop = null)
{
if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus() != 1 || !$this->productSolver->isProductSaleStatusOn($product)) {
return false;
@@ -154,7 +154,7 @@ class OrderShopSolver
public function isOneProductAvailableAddCart(OrderShopInterface $orderShop, $products): bool
{
foreach ($products as $product) {
if ($this->isAvailable($product, 1, true, $orderShop)) {
if ($this->isProductAvailable($product, 1, true, $orderShop)) {
return true;
}
}

+ 21
- 0
Solver/User/VisitorSolver.php 파일 보기

@@ -0,0 +1,21 @@
<?php

namespace Lc\CaracoleBundle\Solver\User;

use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

class VisitorSolver
{
protected ParameterBagInterface $parameterBag;

public function __construct(ParameterBagInterface $parameterBag)
{
$this->parameterBag = $parameterBag;
}

// getCookieNameVisitor
public function getCookieName()
{
return $this->parameterBag->get('app.cookie_name_visitor');
}
}

+ 60
- 14
Twig/StoreTwigExtension.php 파일 보기

@@ -2,6 +2,10 @@

namespace Lc\CaracoleBundle\Twig;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\CaracoleBundle\Repository\Config\TaxRateStore;
use Lc\CaracoleBundle\Repository\Config\UnitStore;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
@@ -16,6 +20,7 @@ use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\ShopBundle\Context\UnitInterface;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

@@ -30,6 +35,7 @@ class StoreTwigExtension extends AbstractExtension
protected TaxRateStore $taxRateStore;
protected ProductCategoryStore $productCategoryStore;
protected OrderShopStore $orderShopStore;
protected SettingSolver $settingSolver;

public function __construct(
MerchantResolver $merchantResolver,
@@ -40,7 +46,8 @@ class StoreTwigExtension extends AbstractExtension
UnitStore $unitStore,
TaxRateStore $taxRateStore,
ProductCategoryStore $productCategoryStore,
OrderShopStore $orderShopStore
OrderShopStore $orderShopStore,
SettingSolver $settingSolver
) {
$this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver;
@@ -51,6 +58,7 @@ class StoreTwigExtension extends AbstractExtension
$this->taxRateStore = $taxRateStore;
$this->productCategoryStore = $productCategoryStore;
$this->orderShopStore = $orderShopStore;
$this->settingSolver = $settingSolver;
}

public function getFunctions()
@@ -65,14 +73,17 @@ class StoreTwigExtension extends AbstractExtension
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
->setSection($this->sectionResolver->getCurrent())
->getParent(false);

new TwigFunction('cart_current', [$this, 'getCartCurrent']),
new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']),
new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']),
new TwigFunction('section_current', [$this, 'getSectionCurrent']),
new TwigFunction('merchant_setting', [$this, 'getMerchantSetting']),
new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']),
new TwigFunction('section_setting', [$this, 'getSectionSetting']),
new TwigFunction('section_setting_current', [$this, 'getSectionSettingCurrent']),
);
}

public function getSections()
@@ -82,21 +93,58 @@ class StoreTwigExtension extends AbstractExtension
->getOnline();
}

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

public function getSectionCurrent(): SectionInterface
{
return $this->sectionResolver->getCurrent();
}

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

public function getMerchants()
public function getMerchantCurrent(): MerchantInterface
{
return $this->merchantStore->getOnline();
return $this->merchantResolver->getCurrent();
}

public function getUserMerchantCurrent(): UserMerchantInterface
{
$this->merchantResolver->getUserMerchant();
}

public function getMerchantSetting(MerchantInterface $merchant, string $settingName): string
{
return $this->settingSolver->getSettingValue($merchant, $settingName);
}

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

public function getSectionSetting(SectionInterface $section, string $settingName): string
{
return $this->settingSolver->getSettingValue($section, $settingName);
}

public function getSectionSettingCurrent(string $settingName): string
{
return $this->settingSolver->getSettingValue($this->getSectionCurrent(), $settingName);
}

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

public function getReminders($params = [])
@@ -122,6 +170,4 @@ class StoreTwigExtension extends AbstractExtension
//TODO mettre à jour une fois les repo fait
return array();
}


}

Loading…
취소
저장