Bläddra i källkod

Refactoring services

packProduct
Guillaume 3 år sedan
förälder
incheckning
9e368d0b8f
6 ändrade filer med 81 tillägg och 41 borttagningar
  1. +1
    -1
      Builder/File/DocumentBuilder.php
  2. +37
    -35
      EventSubscriber/SettingEventSubscriber.php
  3. +39
    -1
      Model/Merchant/MerchantModel.php
  4. +1
    -1
      Model/Product/ProductFamilyModel.php
  5. +1
    -1
      Model/Section/SectionModel.php
  6. +2
    -2
      Repository/Reduction/ReductionCatalogRepositoryQuery.php

+ 1
- 1
Builder/File/DocumentBuilder.php Visa fil

@@ -4,7 +4,7 @@ namespace Lc\CaracoleBundle\Builder\File;

use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Generator\Reference\DocumentReferenceGenerator;
use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator;

class DocumentBuilder
{

+ 37
- 35
EventSubscriber/SettingEventSubscriber.php Visa fil

@@ -78,51 +78,53 @@ class SettingEventSubscriber implements EventSubscriberInterface

public function initSettingsGeneric($type, $settings, $entities, $factory)
{
foreach ($entities as $entity) {
foreach ($settings as $category => $settingList) {
foreach ($settingList as $settingName => $setting) {
$entitySetting = $entity->getSetting($settingName);

if (!$entitySetting) {
// gestion du cas des SectionSetting spécifiques à une section
$createEntitySetting = true;
if ($entity instanceof SectionInterface && isset($setting['section']) && $setting['section'] != $entity) {
$createEntitySetting = false;
}
if($entities) {
foreach ($entities as $entity) {
foreach ($settings as $category => $settingList) {
foreach ($settingList as $settingName => $setting) {
$entitySetting = $entity->getSetting($settingName);

if (!$entitySetting) {
// gestion du cas des SectionSetting spécifiques à une section
$createEntitySetting = true;
if ($entity instanceof SectionInterface && isset($setting['section']) && $setting['section'] != $entity) {
$createEntitySetting = false;
}

if ($createEntitySetting) {
$text = null;
$date = null;
$file = null;
if ($createEntitySetting) {
$text = null;
$date = null;
$file = null;

$fieldValue = isset($setting['default']) ? $setting['default'] : null;
$fieldValue = isset($setting['default']) ? $setting['default'] : null;

if ($setting['field'] == 'text') {
$text = $fieldValue;
} elseif ($setting['field'] == 'date') {
$date = $fieldValue;
} elseif ($setting['field'] == 'file') {
$file = $fieldValue;
}
if ($setting['field'] == 'text') {
$text = $fieldValue;
} elseif ($setting['field'] == 'date') {
$date = $fieldValue;
} elseif ($setting['field'] == 'file') {
$file = $fieldValue;
}

$entitySetting = $factory->create($entity, $setting['name'], $text, $date, $file);
$entitySetting = $factory->create($entity, $setting['name'], $text, $date, $file);

$this->entityManager->persist($entitySetting);
}
} else {
if ($this->settingSolver->getValue($entitySetting) === null
&& isset($setting['default'])
&& $setting['default'] !== null) {
$methodSetValue = 'set' . ucfirst($setting['field']);
$entitySetting->$methodSetValue($setting['default']);
$this->entityManager->update($entitySetting);
$this->entityManager->persist($entitySetting);
}
} else {
if ($this->settingSolver->getValue($entitySetting) === null
&& isset($setting['default'])
&& $setting['default'] !== null) {
$methodSetValue = 'set' . ucfirst($setting['field']);
$entitySetting->$methodSetValue($setting['default']);
$this->entityManager->update($entitySetting);
}
}
}
}
}
}

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

}

+ 39
- 1
Model/Merchant/MerchantModel.php Visa fil

@@ -7,6 +7,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
@@ -53,10 +54,16 @@ abstract class MerchantModel extends AbstractFullEntity
*/
protected $settings;

/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", mappedBy="merchant")
*/
protected $sections;

public function __construct()
{
$this->pointSales = new ArrayCollection();
$this->groupUsers = new ArrayCollection();
$this->settings = new ArrayCollection();
}

public function __toString()
@@ -107,7 +114,7 @@ abstract class MerchantModel extends AbstractFullEntity
/**
* @return Collection|MerchantSettingInterface[]
*/
public function getSettings(): Collection
public function getSettings(): ?Collection
{
return $this->settings;
}
@@ -177,4 +184,35 @@ abstract class MerchantModel extends AbstractFullEntity

return $this;
}

/**
* @return Collection|SectionInterface[]
*/
public function getSections(): ?Collection
{
return $this->sections;
}

public function addSection(SectionInterface $section): self
{
if (!$this->sections->contains($section)) {
$this->sections[] = $section;
$section->setMerchant($this);
}

return $this;
}

public function removeSection(SectionInterface $section): self
{
if ($this->sections->contains($section)) {
$this->sections->removeElement($section);
// set the owning side to null (unless already changed)
if ($section->getMerchant() === $this) {
$section->setMerchant(null);
}
}

return $this;
}
}

+ 1
- 1
Model/Product/ProductFamilyModel.php Visa fil

@@ -323,7 +323,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
protected $section;

/**
* @ORM\ManyToOne((targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
*/
protected $image;


+ 1
- 1
Model/Section/SectionModel.php Visa fil

@@ -25,7 +25,7 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant
use EntitySettingTrait;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

+ 2
- 2
Repository/Reduction/ReductionCatalogRepositoryQuery.php Visa fil

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

public function filterConditionProductFamily(ProductFamilyInterface $productFamily)

Laddar…
Avbryt
Spara