public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
$factory = new PageFactory(); | $factory = new PageFactory(); | ||||
$currentMerchant = $this->get('merchant_resolver')->getCurrent(); | |||||
$currentSection = $this->get('section_resolver')->getCurrent(); | $currentSection = $this->get('section_resolver')->getCurrent(); | ||||
$factory->setMerchant($currentMerchant); | |||||
$factory->setSection($currentSection); | $factory->setSection($currentSection); | ||||
return $factory->create(); | return $factory->create(); | ||||
} | } |
namespace Lc\CaracoleBundle\Controller\Ticket; | namespace Lc\CaracoleBundle\Controller\Ticket; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | |||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | use Lc\CaracoleBundle\Controller\AdminControllerTrait; | ||||
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | ||||
use Lc\CaracoleBundle\Factory\Ticket\TicketFactory; | |||||
class TicketAdminController extends SovTicketAdminController | class TicketAdminController extends SovTicketAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | 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(); | |||||
} | } | ||||
} | } |
class PageFactory extends SovPageFactory | class PageFactory extends SovPageFactory | ||||
{ | { | ||||
use MerchantFactoryTrait; | |||||
use SectionFactoryTrait; | use SectionFactoryTrait; | ||||
public function create(): PageInterface | public function create(): PageInterface | ||||
{ | { | ||||
$page = parent::create(); | $page = parent::create(); | ||||
$page->setMerchant($this->merchant); | |||||
$page->setSection($this->section); | $page->setSection($this->section); | ||||
return $page; | return $page; |
/** | /** | ||||
* @ORM\MappedSuperclass() | * @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") | * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="newsletters") | ||||
*/ | */ | ||||
protected $section; | 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 | ||||
{ | { |
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | use Gedmo\Mapping\Annotation as Gedmo; | ||||
use Doctrine\ORM\Mapping as ORM; | 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\Address\AddressInterface; | ||||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | ||||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | use Lc\CaracoleBundle\Model\File\DocumentInterface; | ||||
use Lc\CaracoleBundle\Model\File\DocumentModel; | use Lc\CaracoleBundle\Model\File\DocumentModel; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | use Lc\SovBundle\Model\Ticket\TicketInterface; | ||||
use Lc\CaracoleBundle\Model\User\VisitorInterface; | use Lc\CaracoleBundle\Model\User\VisitorInterface; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @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") | * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orders", fetch="EAGER") | ||||
*/ | */ | ||||
return null; | return null; | ||||
} | } | ||||
public function getMerchant(): ?MerchantInterface | |||||
{ | |||||
return $this->merchant; | |||||
} | |||||
public function setMerchant(?MerchantInterface $merchant): self | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function getUser(): ?UserInterface | public function getUser(): ?UserInterface | ||||
{ | { | ||||
return $this->user; | return $this->user; |
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\TreeInterface; | use Lc\SovBundle\Doctrine\Extension\TreeInterface; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @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\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | ||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
return $title; | return $title; | ||||
} | } | ||||
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; | return $this->section; |
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | 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\PriceInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyTrait; | use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyTrait; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; | use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | use Gedmo\Mapping\Annotation as Gedmo; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, | abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, | ||||
FilterMerchantInterface | |||||
FilterSectionInterface | |||||
{ | { | ||||
use ProductPropertyTrait; | use ProductPropertyTrait; | ||||
*/ | */ | ||||
protected $updatedBy; | 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") | * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", inversedBy="productFamilies") | ||||
*/ | */ | ||||
*/ | */ | ||||
protected $saleStatus; | 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() | public function __construct() | ||||
{ | { | ||||
return $this->getTitle(); | return $this->getTitle(); | ||||
} | } | ||||
public function getSection(): SectionInterface | |||||
{ | |||||
return $this->section; | |||||
} | |||||
public function setSection(SectionInterface $section): self | |||||
{ | |||||
$this->section = $section; | |||||
return $this; | |||||
} | |||||
public function getAvailableQuantityInherited() | public function getAvailableQuantityInherited() | ||||
{ | { | ||||
$availableQuantity = 0; | $availableQuantity = 0; | ||||
if ($this->getTaxRate()) { | if ($this->getTaxRate()) { | ||||
return $this->getTaxRate(); | return $this->getTaxRate(); | ||||
} else { | } 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 | public function getActiveProducts(): ?bool | ||||
{ | { | ||||
return $this->activeProducts; | return $this->activeProducts; | ||||
return $this; | 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() | public function getFieldBuyingPrice() | ||||
{ | { |
*/ | */ | ||||
protected $section; | 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; | return $this->section; |
namespace Lc\CaracoleBundle\Model\Site; | namespace Lc\CaracoleBundle\Model\Site; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Model\Site\PageModel as SovPageModel; | use Lc\SovBundle\Model\Site\PageModel as SovPageModel; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @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\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages") | ||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | */ | ||||
protected $section; | 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; | return $this->section; | ||||
} | } | ||||
public function setSection(?SectionInterface $section): self | |||||
public function setSection(SectionInterface $section): self | |||||
{ | { | ||||
$this->section = $section; | $this->section = $section; | ||||
namespace Lc\CaracoleBundle\Repository; | namespace Lc\CaracoleBundle\Repository; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
trait MerchantRepositoryQueryTrait | 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); | |||||
} | |||||
} | } | ||||
} | } |
class OrderShopRepositoryQuery extends AbstractRepositoryQuery | class OrderShopRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use MerchantRepositoryQueryTrait; | |||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
public function __construct(OrderShopRepository $repository, PaginatorInterface $paginator) | public function __construct(OrderShopRepository $repository, PaginatorInterface $paginator) |
class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery | class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use MerchantRepositoryQueryTrait; | |||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
public function __construct(ProductCategoryRepository $repository, PaginatorInterface $paginator) | public function __construct(ProductCategoryRepository $repository, PaginatorInterface $paginator) | ||||
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function filterIsParent(){ | |||||
return $this->andWhere('.parent is NULL'); | |||||
} | |||||
} | } |
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
public function getParents(){ | |||||
$query = $this->query->create(); | |||||
$query->filterByMerchant(); | |||||
if($this->section) { | |||||
$query->filterBySection($this->section); | |||||
} | |||||
$query->filterIsParent(); | |||||
} | |||||
} | } |
class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use MerchantRepositoryQueryTrait; | |||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) | public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) |
trait SectionRepositoryQueryTrait | 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); | |||||
} | |||||
} | } | ||||
} | } |
class PageRepositoryQuery extends SovPageRepositoryQuery | class PageRepositoryQuery extends SovPageRepositoryQuery | ||||
{ | { | ||||
use MerchantRepositoryQueryTrait; | |||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
} | } |