Bläddra i källkod

ProductFamilySectionProperty

packProduct
Guillaume 3 år sedan
förälder
incheckning
a1a719a844
6 ändrade filer med 79 tillägg och 14 borttagningar
  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 Visa fil

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

namespace Lc\CaracoleBundle\Builder\Product;


class ProductFamilyBuilder
{


+ 47
- 0
Builder/Product/ProductFamilySectionPropertyBuilder.php Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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();
}
}

Laddar…
Avbryt
Spara