瀏覽代碼

ProductFamilySectionProperty

packProduct
Guillaume 3 年之前
父節點
當前提交
a1a719a844
共有 6 個檔案被更改,包括 79 行新增14 行删除
  1. +0
    -1
      Builder/Product/ProductFamilyBuilder.php
  2. +47
    -0
      Builder/Product/ProductFamilySectionPropertyBuilder.php
  3. +13
    -6
      Container/Product/ProductFamilySectionPropertyContainer.php
  4. +3
    -4
      EventSubscriber/MerchantSectionPropertyEventSubscriber.php
  5. +5
    -1
      Repository/Product/ProductFamilySectionPropertyRepositoryQuery.php
  6. +11
    -2
      Repository/Product/ProductFamilySectionPropertyStore.php

+ 0
- 1
Builder/Product/ProductFamilyBuilder.php 查看文件

@@ -2,7 +2,6 @@

namespace Lc\CaracoleBundle\Builder\Product;


class ProductFamilyBuilder
{


+ 47
- 0
Builder/Product/ProductFamilySectionPropertyBuilder.php 查看文件

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

namespace Lc\CaracoleBundle\Builder\Product;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore;

class ProductFamilySectionPropertyBuilder
{
protected EntityManagerInterface $entityManager;
protected ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory;
protected ProductFamilySectionPropertyStore $productFamilySectionPropertyStore;

public function __construct(
EntityManagerInterface $entityManager,
ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory,
ProductFamilySectionPropertyStore $productFamilySectionPropertyStore
) {
$this->entityManager = $entityManager;
$this->productFamilySectionPropertyFactory = $productFamilySectionPropertyFactory;
$this->productFamilySectionPropertyStore = $productFamilySectionPropertyStore;
}

public function enable(ProductFamilyInterface $productFamily, SectionInterface $section): void
{
$productFamilySectionProperty = $this->productFamilySectionPropertyStore
->setSection($section)
->getOneByProductFamily($productFamily);

if ($productFamilySectionProperty) {
if (!$productFamilySectionProperty->getStatus()) {
$productFamilySectionProperty->setStatus(1);
$this->entityManager->update($productFamilySectionProperty);
}
} else {
$productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily);
$productFamilySectionProperty->setStatus(1);
$this->entityManager->create($productFamilySectionProperty);
}

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

}

+ 13
- 6
Container/Product/ProductFamilySectionPropertyContainer.php 查看文件

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Container\Product;

use App\Definition\Field\Product\ProductFamilyFieldDefinition;
use Lc\CaracoleBundle\Builder\Product\ProductFamilyBuilder;
use Lc\CaracoleBundle\Builder\Product\ProductFamilySectionPropertyBuilder;
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory;
use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery;
@@ -20,18 +21,20 @@ class ProductFamilySectionPropertyContainer
protected ProductFamilySectionPropertySolver $solver;
protected ProductFamilySectionPropertyRepositoryQuery $repositoryQuery;
protected ProductFamilySectionPropertyStore $store;
protected ProductFamilySectionPropertyBuilder $builder;

public function __construct(
ProductFamilySectionPropertyFactory $factory,
ProductFamilySectionPropertySolver $solver,
ProductFamilySectionPropertyRepositoryQuery $repositoryQuery,
ProductFamilySectionPropertyStore $store
)
{
ProductFamilySectionPropertyFactory $factory,
ProductFamilySectionPropertySolver $solver,
ProductFamilySectionPropertyRepositoryQuery $repositoryQuery,
ProductFamilySectionPropertyStore $store,
ProductFamilySectionPropertyBuilder $builder
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->builder = $builder;
}

public function getFactory(): ProductFamilySectionPropertyFactory
@@ -54,4 +57,8 @@ class ProductFamilySectionPropertyContainer
return $this->store;
}

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

+ 3
- 4
EventSubscriber/MerchantSectionPropertyEventSubscriber.php 查看文件

@@ -34,7 +34,8 @@ class MerchantSectionPropertyEventSubscriber implements EventSubscriberInterface

public function setMerchantAndSectionProperties(EntityManagerEvent $event)
{
$entity = $event->getEntity();
// @TODO : toujours d'actualité ?
/*$entity = $event->getEntity();
$entityRepository = $this->em->getRepository(get_class($entity));

if ($entity instanceof FilterSectionInterface) {
@@ -47,9 +48,7 @@ class MerchantSectionPropertyEventSubscriber implements EventSubscriberInterface

if ($entity instanceof FilterMultipleMerchantsInterface) {
$this->setMultipleMerchantProperty($entity, $entityRepository);
}


}*/
}

private function setSectionProperty($entity)

+ 5
- 1
Repository/Product/ProductFamilySectionPropertyRepositoryQuery.php 查看文件

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Product;

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

@@ -15,6 +16,9 @@ class ProductFamilySectionPropertyRepositoryQuery extends AbstractRepositoryQuer
parent::__construct($repository, 'pfsp', $paginator);
}


public function filterByProductFamily(ProductFamilyInterface $productFamily): self
{
return $this->andWhereEqual('productFamily', $productFamily);
}

}

+ 11
- 2
Repository/Product/ProductFamilySectionPropertyStore.php 查看文件

@@ -2,11 +2,12 @@

namespace Lc\CaracoleBundle\Repository\Product;

use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ProductFamilySectionPropertyStore extends AbstractRepository
class ProductFamilySectionPropertyStore extends AbstractStore
{
use SectionStoreTrait;

@@ -24,6 +25,7 @@ class ProductFamilySectionPropertyStore extends AbstractRepository

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$this->addFilterBySectionRequired($query);
return $query;
}

@@ -31,4 +33,11 @@ class ProductFamilySectionPropertyStore extends AbstractRepository
{
return $query;
}

public function getOneByProductFamily(ProductFamilyInterface $productFamily, $query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByProductFamily($productFamily);
return $query->findOne();
}
}

Loading…
取消
儲存