@@ -13,9 +13,7 @@ abstract class PageAdminController extends SovPageAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new PageFactory(); | |||
$currentMerchant = $this->get('merchant_resolver')->getCurrent(); | |||
$currentSection = $this->get('section_resolver')->getCurrent(); | |||
$factory->setMerchant($currentMerchant); | |||
$factory->setSection($currentSection); | |||
return $factory->create(); | |||
} |
@@ -2,18 +2,20 @@ | |||
namespace Lc\CaracoleBundle\Controller\Ticket; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | |||
use Lc\CaracoleBundle\Factory\Ticket\TicketFactory; | |||
class TicketAdminController extends SovTicketAdminController | |||
{ | |||
use AdminControllerTrait; | |||
public function createEntityFromFactory() | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
return $this->ticketFactory | |||
->setMerchant($this->get('merchant_resolver')->getCurrent()) | |||
->create(); | |||
$merchantResolver = $this->get('merchant_resolver'); | |||
$factory = new TicketFactory(); | |||
$factory->setMerchant($merchantResolver->getCurrent()); | |||
return $factory->create(); | |||
} | |||
} |
@@ -9,14 +9,12 @@ use Lc\SovBundle\Model\Site\PageInterface; | |||
class PageFactory extends SovPageFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
use SectionFactoryTrait; | |||
public function create(): PageInterface | |||
{ | |||
$page = parent::create(); | |||
$page->setMerchant($this->merchant); | |||
$page->setSection($this->section); | |||
return $page; |
@@ -12,29 +12,13 @@ use Lc\SovBundle\Model\Newsletter\NewsletterModel as SovNewsletterModel; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class NewsletterModel extends SovNewsletterModel implements FilterMerchantInterface, FilterSectionInterface | |||
abstract class NewsletterModel extends SovNewsletterModel implements FilterSectionInterface | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="newsletters") | |||
*/ | |||
protected $merchant; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="newsletters") | |||
*/ | |||
protected $section; | |||
public function getMerchant(): ?MerchantInterface | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?MerchantInterface $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getSection(): ?SectionInterface | |||
{ |
@@ -6,12 +6,11 @@ use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | |||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | |||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | |||
use Lc\CaracoleBundle\Model\File\DocumentModel; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
use Lc\CaracoleBundle\Model\User\VisitorInterface; | |||
@@ -21,14 +20,8 @@ use Lc\SovBundle\Model\User\UserInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class OrderShopModel extends AbstractLightEntity implements FilterMerchantInterface | |||
abstract class OrderShopModel extends AbstractLightEntity implements FilterSectionInterface | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="productFamilies") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orders", fetch="EAGER") | |||
*/ | |||
@@ -196,18 +189,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterMerch | |||
return null; | |||
} | |||
public function getMerchant(): ?MerchantInterface | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?MerchantInterface $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getUser(): ?UserInterface | |||
{ | |||
return $this->user; |
@@ -5,9 +5,7 @@ namespace Lc\CaracoleBundle\Model\Product; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Extension\TreeInterface; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
@@ -15,15 +13,9 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class ProductCategoryModel extends AbstractFullEntity implements TreeInterface, FilterMerchantInterface, FilterSectionInterface | |||
abstract class ProductCategoryModel extends AbstractFullEntity implements TreeInterface, FilterSectionInterface | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="productCategories") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
@@ -66,19 +58,6 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn | |||
return $title; | |||
} | |||
public function getMerchant(): MerchantInterface | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(MerchantInterface $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getSection(): SectionInterface | |||
{ | |||
return $this->section; |
@@ -5,12 +5,11 @@ namespace Lc\CaracoleBundle\Model\Product; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyTrait; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
@@ -20,7 +19,7 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, | |||
FilterMerchantInterface | |||
FilterSectionInterface | |||
{ | |||
use ProductPropertyTrait; | |||
@@ -161,12 +160,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
*/ | |||
protected $updatedBy; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="productFamilies") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", inversedBy="productFamilies") | |||
*/ | |||
@@ -319,10 +312,12 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
*/ | |||
protected $saleStatus; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="productFamilies") | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $sections; | |||
protected $section; | |||
public function __construct() | |||
{ | |||
@@ -335,6 +330,18 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this->getTitle(); | |||
} | |||
public function getSection(): SectionInterface | |||
{ | |||
return $this->section; | |||
} | |||
public function setSection(SectionInterface $section): self | |||
{ | |||
$this->section = $section; | |||
return $this; | |||
} | |||
public function getAvailableQuantityInherited() | |||
{ | |||
$availableQuantity = 0; | |||
@@ -366,22 +373,9 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
if ($this->getTaxRate()) { | |||
return $this->getTaxRate(); | |||
} else { | |||
return $this->getMerchant()->getTaxRate(); | |||
return $this->getSection()->getMerchant()->getTaxRate(); | |||
} | |||
} | |||
public function getMerchant(): ?MerchantInterface | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?MerchantInterface $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getActiveProducts(): ?bool | |||
{ | |||
return $this->activeProducts; | |||
@@ -953,31 +947,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
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; | |||
} | |||
return $this; | |||
} | |||
public function removeSection(SectionInterface $section): self | |||
{ | |||
if ($this->sections->contains($section)) { | |||
$this->sections->removeElement($section); | |||
} | |||
return $this; | |||
} | |||
public function getFieldBuyingPrice() | |||
{ |
@@ -25,18 +25,6 @@ abstract class ReminderModel extends SovReminderModel implements FilterMerchantI | |||
*/ | |||
protected $section; | |||
public function getMerchant(): MerchantInterface | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(MerchantInterface $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getSection(): ?SectionInterface | |||
{ | |||
return $this->section; |
@@ -3,48 +3,29 @@ | |||
namespace Lc\CaracoleBundle\Model\Site; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Model\Site\PageModel as SovPageModel; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class PageModel extends SovPageModel implements FilterMerchantInterface, FilterSectionInterface | |||
abstract class PageModel extends SovPageModel implements FilterSectionInterface | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="pages") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $section; | |||
public function getMerchant(): ?MerchantInterface | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?MerchantInterface $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getSection(): ?SectionInterface | |||
public function getSection(): SectionInterface | |||
{ | |||
return $this->section; | |||
} | |||
public function setSection(?SectionInterface $section): self | |||
public function setSection(SectionInterface $section): self | |||
{ | |||
$this->section = $section; | |||
@@ -3,13 +3,31 @@ | |||
namespace Lc\CaracoleBundle\Repository; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
trait MerchantRepositoryQueryTrait | |||
{ | |||
public function filterByMerchant(MerchantInterface $merchant) | |||
protected MerchantInterface $merchant; | |||
public function setMerchant(MerchantInterface $merchant) | |||
{ | |||
return $this | |||
->andWhere('.merchant = :merchant') | |||
->setParameter(':merchant', $merchant); | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function filterByMerchant(MerchantInterface $merchant = null) | |||
{ | |||
$this->andWhere('.merchant = :merchant'); | |||
if(is_null($merchant)) { | |||
if(is_null($this->merchant)){ | |||
throw new \ErrorException('Aucun merchant défini'); | |||
} | |||
return $this->setParameter(':merchant', $this->merchant); | |||
}else{ | |||
return $this->setParameter(':merchant', $merchant); | |||
} | |||
} | |||
} |
@@ -9,7 +9,6 @@ use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||
class OrderShopRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
use MerchantRepositoryQueryTrait; | |||
use SectionRepositoryQueryTrait; | |||
public function __construct(OrderShopRepository $repository, PaginatorInterface $paginator) |
@@ -9,11 +9,15 @@ use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||
class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
use MerchantRepositoryQueryTrait; | |||
use SectionRepositoryQueryTrait; | |||
public function __construct(ProductCategoryRepository $repository, PaginatorInterface $paginator) | |||
{ | |||
parent::__construct($repository, 'r', $paginator); | |||
} | |||
public function filterIsParent(){ | |||
return $this->andWhere('.parent is NULL'); | |||
} | |||
} |
@@ -12,4 +12,16 @@ class ProductCategoryStore extends AbstractStore | |||
{ | |||
$this->query = $query; | |||
} | |||
public function getParents(){ | |||
$query = $this->query->create(); | |||
$query->filterByMerchant(); | |||
if($this->section) { | |||
$query->filterBySection($this->section); | |||
} | |||
$query->filterIsParent(); | |||
} | |||
} |
@@ -9,7 +9,6 @@ use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||
class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
use MerchantRepositoryQueryTrait; | |||
use SectionRepositoryQueryTrait; | |||
public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) |
@@ -6,10 +6,26 @@ use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
trait SectionRepositoryQueryTrait | |||
{ | |||
public function filterBySection(SectionInterface $section) | |||
protected SectionInterface $section; | |||
public function setSection(SectionInterface $section) | |||
{ | |||
$this->section = $section; | |||
return $this; | |||
} | |||
public function filterBySection(SectionInterface $section = null) | |||
{ | |||
return $this | |||
->andWhere('.section = :section') | |||
->setParameter(':section', $section); | |||
$this->andWhere('.section = :section'); | |||
if(is_null($section)) { | |||
if(is_null($this->section)){ | |||
throw new \ErrorException('Aucun merchant défini'); | |||
} | |||
return $this->setParameter(':section', $this->section); | |||
}else{ | |||
return $this->setParameter(':section', $section); | |||
} | |||
} | |||
} |
@@ -8,7 +8,6 @@ use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery; | |||
class PageRepositoryQuery extends SovPageRepositoryQuery | |||
{ | |||
use MerchantRepositoryQueryTrait; | |||
use SectionRepositoryQueryTrait; | |||
} |