Browse Source

Refactoring Repository & AdminController

reduction
Fab 4 years ago
parent
commit
65073aee7e
36 changed files with 714 additions and 399 deletions
  1. +15
    -0
      ShopBundle/Context/DefaultRepositoryInterface.php
  2. +8
    -0
      ShopBundle/Context/FilterMultipleMerchantsInterface.php
  3. +6
    -1
      ShopBundle/Context/GlobalParamInterface.php
  4. +8
    -0
      ShopBundle/Context/SluggableInterface.php
  5. +54
    -146
      ShopBundle/Controller/Admin/AdminController.php
  6. +10
    -1
      ShopBundle/Controller/ApiController.php
  7. +99
    -0
      ShopBundle/EventSubscriber/EditEventSubscriber.php
  8. +17
    -24
      ShopBundle/EventSubscriber/ListEventSubscriber.php
  9. +4
    -16
      ShopBundle/Model/AbstractDocumentEntity.php
  10. +2
    -0
      ShopBundle/Model/AbstractEntity.php
  11. +3
    -3
      ShopBundle/Model/Merchant.php
  12. +10
    -9
      ShopBundle/Model/PointSale.php
  13. +2
    -1
      ShopBundle/Model/ProductCategory.php
  14. +26
    -0
      ShopBundle/Model/SluggableTrait.php
  15. +51
    -0
      ShopBundle/Repository/AddressRepository.php
  16. +49
    -27
      ShopBundle/Repository/BaseRepository.php
  17. +20
    -0
      ShopBundle/Repository/CreditConfigRepository.php
  18. +20
    -0
      ShopBundle/Repository/CreditHistoryRepository.php
  19. +21
    -0
      ShopBundle/Repository/DocumentDeliveryNoteRepository.php
  20. +23
    -0
      ShopBundle/Repository/DocumentInvoiceRepository.php
  21. +23
    -0
      ShopBundle/Repository/DocumentQuotationRepository.php
  22. +4
    -44
      ShopBundle/Repository/MerchantConfigRepository.php
  23. +20
    -0
      ShopBundle/Repository/MerchantRepository.php
  24. +20
    -0
      ShopBundle/Repository/OrderProductRepository.php
  25. +21
    -0
      ShopBundle/Repository/OrderShopRepository.php
  26. +21
    -0
      ShopBundle/Repository/OrderStatusHistoryRepository.php
  27. +11
    -41
      ShopBundle/Repository/PageRepository.php
  28. +21
    -0
      ShopBundle/Repository/PointSaleDayInfoRepository.php
  29. +5
    -38
      ShopBundle/Repository/PointSaleRepository.php
  30. +4
    -8
      ShopBundle/Repository/ProductCategoryRepository.php
  31. +11
    -40
      ShopBundle/Repository/ProductFamilyRepository.php
  32. +21
    -0
      ShopBundle/Repository/ProductRepository.php
  33. +21
    -0
      ShopBundle/Repository/TaxRateRepository.php
  34. +21
    -0
      ShopBundle/Repository/UnitRepository.php
  35. +21
    -0
      ShopBundle/Repository/UserRepository.php
  36. +21
    -0
      ShopBundle/Repository/VisitorRepository.php

+ 15
- 0
ShopBundle/Context/DefaultRepositoryInterface.php View File

<?php

namespace Lc\ShopBundle\Context;


interface DefaultRepositoryInterface
{

/**
* Retourne la class ou l'interface correspondant à ce repository
*
* @return string
*/
public function getInterfaceClass();
}

+ 8
- 0
ShopBundle/Context/FilterMultipleMerchantsInterface.php View File

<?php

namespace Lc\ShopBundle\Context ;

interface FilterMultipleMerchantsInterface
{

}

+ 6
- 1
ShopBundle/Context/GlobalParamInterface.php View File



interface GlobalParamInterface interface GlobalParamInterface
{ {

/**
* Retourne le merchant courant en focntion du user ou du cookie du visitor
*
* @return MerchantInterface
*/
public function getCurrentMerchant();
} }

+ 8
- 0
ShopBundle/Context/SluggableInterface.php View File

<?php

namespace Lc\ShopBundle\Context;

interface SluggableInterface
{

}

+ 54
- 146
ShopBundle/Controller/Admin/AdminController.php View File



namespace Lc\ShopBundle\Controller\Admin; namespace Lc\ShopBundle\Controller\Admin;


use App\Entity\MerchantConfig;
use Lc\ShopBundle\Context\AddressInterface;
use Lc\ShopBundle\Repository\MerchantConfigRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController; use EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use FOS\UserBundle\Model\UserManagerInterface; use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\MerchantConfigInterface;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\MerchantInterface; use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\SortableInterface; use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface; use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TreeInterface; use Lc\ShopBundle\Context\TreeInterface;
use Lc\ShopBundle\Form\AbstractEditPositionType; use Lc\ShopBundle\Form\AbstractEditPositionType;
use Lc\ShopBundle\Form\ChoiceProductCategoryType;
use Lc\ShopBundle\Form\PriceType;
use Lc\ShopBundle\Form\Widget\PriceWidgetType;
use Lc\ShopBundle\Services\Utils; use Lc\ShopBundle\Services\Utils;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\CollectionType;
{ {
protected $security; protected $security;
protected $userManager; protected $userManager;
protected $em ;
protected $utils ;

public function __construct(
Security $security,
UserManagerInterface $userManager,
EntityManagerInterface $em,
Utils $utils)
protected $em;
protected $utils;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils)
{ {
$this->security = $security; $this->security = $security;
$this->userManager = $userManager; $this->userManager = $userManager;
$this->em = $em ;
$this->utils = $utils ;
$this->em = $em;
$this->utils = $utils;
} }


/**
* Réécriture de show action pr rediriger vers l'édition
*/
public function showAction() public function showAction()
{ {
$id = $this->request->query->get('id'); $id = $this->request->query->get('id');
'action' => 'edit', 'action' => 'edit',
'entity' => $entity, 'entity' => $entity,
'id' => $id 'id' => $id
]) ;
]);
}


/**
* Réécriture de removeEntity pour passer les status à -1
*/
protected function removeEntity($entity)
{
if ($entity instanceof StatusInterface) {
$entity->setStatus(-1);
$this->em->persist($entity);
$this->em->flush();

} else {
parent::removeEntity($entity);
}
} }


protected function commonDqlFilterQueryBuilder($entityClass, $dqlFilter) protected function commonDqlFilterQueryBuilder($entityClass, $dqlFilter)


protected function commonQueryFilter($entityClass, $queryBuilder) protected function commonQueryFilter($entityClass, $queryBuilder)
{ {
if ($entityClass == 'App\Entity\PointSale') {
$queryBuilder->andWhere(':currentMerchant MEMBER OF entity.merchant')

if (new $entityClass instanceof FilterMultipleMerchantsInterface) {
$queryBuilder->andWhere(':currentMerchant MEMBER OF entity.merchants')
->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()); ->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId());
} }




protected function createSearchQueryBuilder($entityClass, $searchQuery, array $searchableFields, $sortField = null, $sortDirection = null, $dqlFilter = null) protected function createSearchQueryBuilder($entityClass, $searchQuery, array $searchableFields, $sortField = null, $sortDirection = null, $dqlFilter = null)
{ {
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter) ;
$queryBuilder = parent::createSearchQueryBuilder($entityClass, $searchQuery, $searchableFields, $sortField, $sortDirection, $dqlFilter) ;
$this->commonQueryFilter($entityClass, $queryBuilder) ;
return $queryBuilder ;
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter);
$queryBuilder = parent::createSearchQueryBuilder($entityClass, $searchQuery, $searchableFields, $sortField, $sortDirection, $dqlFilter);
$this->commonQueryFilter($entityClass, $queryBuilder);
return $queryBuilder;
} }


protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null)
{ {
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter) ;
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter);
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); $queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter);
$this->commonQueryFilter($entityClass, $queryBuilder) ;
return $queryBuilder ;
$this->commonQueryFilter($entityClass, $queryBuilder);
return $queryBuilder;
} }




]; ];
} }


protected function removeEntity($entity)
{
if(method_exists($entity, 'setStatus')) {
$entity->setStatus(-1);
$this->em->persist($entity);
$this->em->flush();
}
else {
parent::removeEntity($entity);
}
}

public function updateEntity($entity)
{
$this->setUpdated($entity);
$this->setAddressCreatedBy($entity) ;
parent::updateEntity($entity);
}


public function persistEntity($entity)
{


if ($entity instanceof StatusInterface) {
$entity->setStatus(1);
}

if ($entity instanceof SortableInterface) {
if ($entity instanceof TreeInterface) {
if ($entity->getParent()) {
$total = $this->em->getRepository($this->entity['class'])->count(array('status' => 1, 'parent' => $entity->getParent()->getId()));
$entity->setPosition($entity->getParent()->getId() . '_' . $total);
} else {
$total = $this->em->getRepository($this->entity['class'])->count(array('status' => 1, 'parent' => null));
$entity->setPosition($total);
}
} else {
$total = $this->em->getRepository($this->entity['class'])->count(array('status' => 1));
$entity->setPosition($total);
}
}
if (method_exists($entity, 'setMerchant')) {
$entity->setMerchant($this->security->getUser()->getMerchant());
}

if (method_exists($entity, 'addMerchant')) {
if ($entity->getMerchant()->isEmpty()) {
$entity->addMerchant($this->security->getUser()->getMerchant());
}
}

if (method_exists($entity, 'setCreatedBy')) {
$entity->setCreatedBy($this->security->getUser());
}


$this->setUpdated($entity);
$this->setAddressCreatedBy($entity) ;

parent::persistEntity($entity);
}

public function setAddressCreatedBy($entity)
{
if (method_exists($entity, 'getAddress') && $entity->getAddress()) {
$entity->getAddress()->setCreatedBy($this->security->getUser());
$entity->getAddress()->setCreatedAt(new \DateTime());
}

if (method_exists($entity, 'getAddresses')
&& $entity->getAddresses() && count($entity->getAddresses()) > 0) {
foreach($entity->getAddresses() as $address) {
$address->setCreatedBy($this->security->getUser()) ;
$address->setCreatedAt(new \DateTime()) ;
}
}
}

public function setUpdated($entity)
{

if (method_exists($entity, 'setUpdatedBy')) {
$entity->setUpdatedBy($this->security->getUser());
}

if (method_exists($entity, 'getAddress') && $entity->getAddress()) {
$entity->getAddress()->setUpdatedBy($this->security->getUser());
}

if (method_exists($entity, 'getAddresses')
&& $entity->getAddresses() && count($entity->getAddresses()) > 0) {

foreach($entity->getAddresses() as $address) {
$address->setUpdatedBy($this->security->getUser()) ;
$address->setUpdatedAt(new \DateTime()) ;
if(!$address->getCreatedBy()) {
$address->setCreatedBy($this->security->getUser()) ;
$address->setCreatedAt(new \DateTime()) ;
}
}
}
}


public function listChildrenAction() public function listChildrenAction()
{ {


} }
//to do récupérer les élements hors ligne et incrémenter position //to do récupérer les élements hors ligne et incrémenter position
foreach ($repo->findAllOfflineAndDelete() as $offlineEntity) {
foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) {
$latsPos++; $latsPos++;
$offlineEntity->setPosition($latsPos); $offlineEntity->setPosition($latsPos);
$this->em->persist($offlineEntity); $this->em->persist($offlineEntity);
// @TODO : À passer dans le controller de App // @TODO : À passer dans le controller de App
$formBuilder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) { $formBuilder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
$form = $event->getForm(); $form = $event->getForm();
$allChilds = $form->all() ;
foreach($allChilds as $child) {
$type = $child->getConfig()->getType()->getInnerType() ;
$allChilds = $form->all();
foreach ($allChilds as $child) {
$type = $child->getConfig()->getType()->getInnerType();


if($type instanceof EntityType) {
$passedOptions = $child->getConfig()->getOptions() ;
$classImplements = class_implements($passedOptions['class']) ;
if ($type instanceof EntityType) {
$passedOptions = $child->getConfig()->getOptions();
$classImplements = class_implements($passedOptions['class']);


if(in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements)) {
if (in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements)) {


$propertyMerchant = 'merchant' ;
$propertyMerchant = 'merchant';


$form->add($child->getName(), EntityType::class, array( $form->add($child->getName(), EntityType::class, array(
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), 'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(),
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false, 'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false,
'placeholder' => '--', 'placeholder' => '--',
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant) { 'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant) {
$queryBuilder = $repo->createQueryBuilder('e') ;
$propertyMerchant = 'e.'.$propertyMerchant ;
$queryBuilder = $repo->createQueryBuilder('e');
$propertyMerchant = 'e.' . $propertyMerchant;


if($passedOptions['class'] == 'App\Entity\PointSale') {
$queryBuilder->where(':currentMerchant MEMBER OF '.$propertyMerchant) ;
}
else {
$queryBuilder->where($propertyMerchant.' = :currentMerchant') ;
if ($passedOptions['class'] == 'App\Entity\PointSale') {
$queryBuilder->where(':currentMerchant MEMBER OF ' . $propertyMerchant);
} else {
$queryBuilder->where($propertyMerchant . ' = :currentMerchant');
} }


$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()) ;
return $queryBuilder ;
$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId());
return $queryBuilder;
}, },
'required' => $passedOptions['required'], 'required' => $passedOptions['required'],
) )

+ 10
- 1
ShopBundle/Controller/ApiController.php View File



use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductInterface; use Lc\ShopBundle\Context\ProductInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;


class ApiController extends AbstractController class ApiController extends AbstractController


public function getEntity($entity, $id) public function getEntity($entity, $id)
{ {

$repo = $this->em->getRepository(ProductCategoryInterface::class);
$data = $repo->findBy(array());
dump($data);



if($entity == 'product'){ if($entity == 'product'){
$repo = $this->em->getRepository(ProductInterface::class); $repo = $this->em->getRepository(ProductInterface::class);
$data = $repo->find($id); $data = $repo->find($id);
); );
} }


return new JsonResponse($data);
return new Response('<html><body>NICHE</body></html>');
} }


} }

+ 99
- 0
ShopBundle/EventSubscriber/EditEventSubscriber.php View File

<?php
# src/EventSubscriber/EasyAdminSubscriber.php
namespace Lc\ShopBundle\EventSubscriber;

use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\ShopBundle\Services\GlobalParam;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\Security\Core\Security;


class EditEventSubscriber implements EventSubscriberInterface
{
public $globalParam;

public function __construct(GlobalParam $globalParam)
{
$this->globalParam = $globalParam;

}

public static function getSubscribedEvents()
{
return array(
'easy_admin.pre_persist' => array('persistCommonProperty'),
'easy_admin.post_update' => array('updateCommonProperty'),
);
}


public function persistCommonProperty(GenericEvent $event)
{
$entity = $event->getSubject();
$em = $event->getArgument('em');

$entityRepo = $em->getRepository(get_class($entity));

if ($entity instanceof StatusInterface) {
$this->setStatusProperty($entity);
}

if ($entity instanceof SortableInterface) {
$this->setSortableProperty($entity, $entityRepo);
}

if ($entity instanceof FilterMerchantInterface) {
$this->setMerchantProperty($entity);
}

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


public function updateCommonProperty(GenericEvent $event){

/* $this->setUpdated($entity);
$this->setAddressCreatedBy($entity) ;*/
}

private function setStatusProperty($entity){
$entity->setStatus(1);

return $entity;
}

private function setSortableProperty($entity, $entityRepo){
if ($entity instanceof TreeInterface) {
if ($entity->getParent()) {
$total = $entityRepo->count(array('status' => 1, 'parent' => $entity->getParent()->getId()));
$entity->setPosition($entity->getParent()->getId() . '_' . $total);
} else {
$total = $entityRepo->count(array('status' => 1, 'parent' => null));
$entity->setPosition($total);
}
} else {
$total = $entityRepo->count(array('status' => 1));
$entity->setPosition($total);
}
return $entity;
}

private function setMerchantProperty($entity){
$entity->setMerchant($this->globalParam->getCurrentMerchant());
}

private function setMultipleMerchantProperty($entity){
if ($entity->getMerchants()->isEmpty()) {
$entity->addMerchant($this->globalParam->getCurrentMerchant());
}
}

}

ShopBundle/EventSubscriber/EasyAdminSubscriber.php → ShopBundle/EventSubscriber/ListEventSubscriber.php View File

namespace Lc\ShopBundle\EventSubscriber; namespace Lc\ShopBundle\EventSubscriber;


use Lc\ShopBundle\Context\FilterMerchantInterface; use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\StatusInterface; use Lc\ShopBundle\Context\StatusInterface;
use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;




class EasyAdminSubscriber implements EventSubscriberInterface
class ListEventSubscriber implements EventSubscriberInterface
{ {
public $security; public $security;


$criteria['merchant'] = $currentMerchant; $criteria['merchant'] = $currentMerchant;
} }


if ($entityObject instanceof FilterMultipleMerchantsInterface) {


if($entityObject instanceof StatusInterface) {
for ($status = -1; $status <= 1; $status++) {
$criteria['status'] = $status;
if ($status == -1) {
$paginator->nbResultsDeleted = $entityRepo->count($criteria);
} elseif ($status == 0) {
$paginator->nbResultsOffline = $entityRepo->count($criteria);
} else if ($status == 1) {
$paginator->nbResultsOnline = $entityRepo->count($criteria);
}
}
}
}
// TODO : Filter sur le merchant courant; Pour le moment dans ce contexte on ne charge rien de plus, par de nbResultsOnline en fonction du merchant


public function setBlogPostSlug(GenericEvent $event)
{
$entity = $event->getSubject();
}else {


if (!($entity instanceof BlogPost)) {
return;
if ($entityObject instanceof StatusInterface) {
for ($status = -1; $status <= 1; $status++) {
$criteria['status'] = $status;
if ($status == -1) {
$paginator->nbResultsDeleted = $entityRepo->count($criteria);
} elseif ($status == 0) {
$paginator->nbResultsOffline = $entityRepo->count($criteria);
} else if ($status == 1) {
$paginator->nbResultsOnline = $entityRepo->count($criteria);
}
}
}
} }

$slug = $this->slugger->slugify($entity->getTitle());
$entity->setSlug($slug);

$event['entity'] = $entity;
} }
} }

+ 4
- 16
ShopBundle/Model/AbstractDocumentEntity.php View File



use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
use Lc\ShopBundle\Context\SluggableInterface;
use Lc\ShopBundle\Context\SortableInterface; use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface; use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Model\AbstractEntity; use Lc\ShopBundle\Model\AbstractEntity;
/** /**
* @ORM\MappedSuperclass * @ORM\MappedSuperclass
*/ */
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface
{ {
use SortableTrait; use SortableTrait;


use StatusTrait; use StatusTrait;


use SluggableTrait;

/** /**
* @ORM\Column(type="string", length=255) * @ORM\Column(type="string", length=255)
*/ */
protected $title; protected $title;


/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Slug(fields={"title"})
*/
protected $slug;


/** /**
* @ORM\Column(type="text", nullable=true) * @ORM\Column(type="text", nullable=true)
return $this; return $this;
} }


public function getSlug(): ?string
{
return $this->slug;
}

public function setSlug(string $slug): self
{
$this->slug = $slug;


return $this;
}


public function getDescription(): ?string public function getDescription(): ?string
{ {

+ 2
- 0
ShopBundle/Model/AbstractEntity.php View File

protected $updatedAt; protected $updatedAt;


/** /**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface") * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */
protected $createdBy; protected $createdBy;


/** /**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface") * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */

+ 3
- 3
ShopBundle/Model/Merchant.php View File

protected $taxRate; protected $taxRate;


/** /**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\PointSaleInterface", mappedBy="merchant")
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\PointSaleInterface", mappedBy="merchants")
*/ */
protected $pointSales; protected $pointSales;


/** /**
* @ORM\OneToMany(targetEntity="App\Entity\ProductCategory", mappedBy="merchant", orphanRemoval=true) * @ORM\OneToMany(targetEntity="App\Entity\ProductCategory", mappedBy="merchant", orphanRemoval=true)
*/ */
private $productCategories;
protected $productCategories;


public function __construct() public function __construct()
{ {


return $this; return $this;
} }
}
}

+ 10
- 9
ShopBundle/Model/PointSale.php View File

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\ShopBundle\Context\FilterMultipleMerchantsInterface;


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
abstract class PointSale extends AbstractDocumentEntity
abstract class PointSale extends AbstractDocumentEntity implements FilterMultipleMerchantsInterface
{ {
/** /**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="pointSales") * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="pointSales")
*/ */
protected $merchant;
protected $merchants;


/** /**
* @ORM\Column(type="string", length=63, nullable=true) * @ORM\Column(type="string", length=63, nullable=true)


public function __construct() public function __construct()
{ {
$this->merchant = new ArrayCollection();
$this->merchants = new ArrayCollection();
$this->pointSaleDayInfos = new ArrayCollection(); $this->pointSaleDayInfos = new ArrayCollection();
} }


/** /**
* @return Collection|Merchant[] * @return Collection|Merchant[]
*/ */
public function getMerchant(): Collection
public function getMerchants(): Collection
{ {
return $this->merchant;
return $this->merchants;
} }


public function addMerchant(Merchant $merchant): self public function addMerchant(Merchant $merchant): self
{ {
if (!$this->merchant->contains($merchant)) {
$this->merchant[] = $merchant;
if (!$this->merchants->contains($merchant)) {
$this->merchants[] = $merchant;
} }


return $this; return $this;


public function removeMerchant(Merchant $merchant): self public function removeMerchant(Merchant $merchant): self
{ {
if ($this->merchant->contains($merchant)) {
$this->merchant->removeElement($merchant);
if ($this->merchants->contains($merchant)) {
$this->merchants->removeElement($merchant);
} }


return $this; return $this;

+ 2
- 1
ShopBundle/Model/ProductCategory.php View File

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\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\TreeInterface; use Lc\ShopBundle\Context\TreeInterface;


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
abstract class ProductCategory extends AbstractDocumentEntity implements TreeInterface
abstract class ProductCategory extends AbstractDocumentEntity implements TreeInterface, FilterMerchantInterface
{ {


/** /**

+ 26
- 0
ShopBundle/Model/SluggableTrait.php View File

<?php

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;

trait SluggableTrait
{
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Slug(fields={"title"})
*/
protected $slug;

public function getSlug(): ?string
{
return $this->slug;
}

public function setSlug(string $slug): self
{
$this->slug = $slug;

return $this;
}
}

+ 51
- 0
ShopBundle/Repository/AddressRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;


use Lc\ShopBundle\Context\AddressInterface;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;


/**
* @method AddressInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method AddressInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method AddressInterface[] findAll()
* @method AddressInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class AddressRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return AddressInterface::class;
}

// /**
// * @return Address[] Returns an array of Address objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->orderBy('a.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Address
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 49
- 27
ShopBundle/Repository/BaseRepository.php View File

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\GlobalParamInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;


class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface
{ {
public $globalParam;

/** /**
* @param string $entityClass The class name of the entity this repository manages * @param string $entityClass The class name of the entity this repository manages
*/ */
public function __construct(EntityManager $entityManager, $entityClass)
{
parent::__construct($entityManager, $entityManager->getClassMetadata($entityClass));
}

public function findAllOfflineAndDelete()
public function __construct(EntityManager $entityManager, GlobalParamInterface $globalParam)
{ {

return $this->createQueryBuilder('e')
->andWhere('e.status < = 0')
->orderBy('e.status', "DESC")
->getQuery()
->getResult();

$this->globalParam = $globalParam;
parent::__construct($entityManager, $entityManager->getClassMetadata($this->getInterfaceClass()));
} }


public function filterByMerchant($merchant){
return $this->createQueryBuilder('e')
->where('e.merchant = :currentMerchant')
->setParameter('currentMerchant', $merchant->getId())
->getQuery()
->getResult();
}


public function findByMerchantQuery($merchant) public function findByMerchantQuery($merchant)
{ {
->setParameter('currentMerchant', $merchant->getId()) ; ->setParameter('currentMerchant', $merchant->getId()) ;
} }


public function findOneByDevAlias($devAlias, $merchant)
public function findAll()
{
return $this->findBy(array());
}

public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{ {
return $this->findByMerchantQuery($merchant)
->where('e.devAlias = :devAlias')
->andWhere('e.status = 1')
->setParameter('devAlias', $devAlias)
->getQuery()
->getResult();
$className = $this->getClassMetadata()->getName();
$entity = new $className;

if($entity instanceof StatusInterface){
if (!isset($criteria['status'])) $criteria['status'] = 1;
if ($criteria['status'] === false) unset($criteria['status']);
}

if($entity instanceof FilterMerchantInterface){
if (!isset($criteria['merchant'])) $criteria['merchant'] = $this->globalParam->getCurrentMerchant();
if ($criteria['merchant'] === false) unset($criteria['merchant']);
}


return parent::findBy($criteria, $orderBy, $limit, $offset);

} }


public function findOneBy(array $criteria, array $orderBy = null)
{

$className = $this->getClassMetadata()->getName();
$entity = new $className;

if($entity instanceof StatusInterface){
if (!isset($criteria['status'])) $criteria['status'] = 1;
if ($criteria['status'] === false) unset($criteria['status']);
}

if($entity instanceof FilterMerchantInterface){
if (!isset($criteria['merchant'])) $criteria['merchant'] = $this->globalParam->getCurrentMerchant();
if ($criteria['merchant'] === false) unset($criteria['merchant']);
}

return parent::findOneBy($criteria, $orderBy);
}


} }

+ 20
- 0
ShopBundle/Repository/CreditConfigRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\CreditConfigInterface;

/**
* @method CreditConfigInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method CreditConfigInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method CreditConfigInterface[] findAll()
* @method CreditConfigInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CreditConfigRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return CreditConfigInterface::class;
}
}

+ 20
- 0
ShopBundle/Repository/CreditHistoryRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\CreditHistoryInterface;

/**
* @method CreditHistoryInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method CreditHistoryInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method CreditHistoryInterface[] findAll()
* @method CreditHistoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CreditHistoryRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return CreditHistoryInterface::class;
}
}

+ 21
- 0
ShopBundle/Repository/DocumentDeliveryNoteRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\DocumentDeliveryNoteInterface;

/**
* @method DocumentDeliveryNoteInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method DocumentDeliveryNoteInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method DocumentDeliveryNoteInterface[] findAll()
* @method DocumentDeliveryNoteInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DocumentDeliveryNoteRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return DocumentDeliveryNoteInterface::class;
}

}

+ 23
- 0
ShopBundle/Repository/DocumentInvoiceRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use App\Entity\DocumentInvoice;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\DocumentInvoiceInterface;

/**
* @method DocumentInvoice|null find($id, $lockMode = null, $lockVersion = null)
* @method DocumentInvoice|null findOneBy(array $criteria, array $orderBy = null)
* @method DocumentInvoice[] findAll()
* @method DocumentInvoice[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DocumentInvoiceRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return DocumentInvoiceInterface::class;
}
}

+ 23
- 0
ShopBundle/Repository/DocumentQuotationRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use App\Entity\DocumentQuotation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\DocumentQuotationInterface;

/**
* @method DocumentQuotation|null find($id, $lockMode = null, $lockVersion = null)
* @method DocumentQuotation|null findOneBy(array $criteria, array $orderBy = null)
* @method DocumentQuotation[] findAll()
* @method DocumentQuotation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DocumentQuotationRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return DocumentQuotationInterface::class;
}
}

+ 4
- 44
ShopBundle/Repository/MerchantConfigRepository.php View File

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\MerchantConfigInterface; use Lc\ShopBundle\Context\MerchantConfigInterface;
use Lc\ShopBundle\Repository\BaseRepository; use Lc\ShopBundle\Repository\BaseRepository;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
* @method MerchantConfig|null findOneBy(array $criteria, array $orderBy = null) * @method MerchantConfig|null findOneBy(array $criteria, array $orderBy = null)
* @method MerchantConfig[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method MerchantConfig[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class MerchantConfigRepository extends BaseRepository
class MerchantConfigRepository extends BaseRepository implements DefaultRepositoryInterface
{ {
protected $security ;

public function __construct(EntityManager $entityManager, Security $security)
{
$this->security = $security ;
parent::__construct($entityManager, MerchantConfigInterface::class);
}

public function findAll()
{
return $this->createQueryBuilder('m')
->andWhere('m.merchant = :currentMerchant')
->setParameter('currentMerchant', $this->security->getUser()->getMerchant()->getId())
->getQuery()
->getResult();
}

// /**
// * @return MerchantConfig[] Returns an array of MerchantConfig objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('m')
->andWhere('m.exampleField = :val')
->setParameter('val', $value)
->orderBy('m.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?MerchantConfig
public function getInterfaceClass()
{ {
return $this->createQueryBuilder('m')
->andWhere('m.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
return MerchantConfigInterface::class;
} }
*/
} }

+ 20
- 0
ShopBundle/Repository/MerchantRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\MerchantInterface;

/**
* @method MerchantInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method MerchantInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method MerchantInterface[] findAll()
* @method MerchantInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MerchantRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return MerchantInterface::class;
}
}

+ 20
- 0
ShopBundle/Repository/OrderProductRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\OrderProductInterface;

/**
* @method OrderProductInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method OrderProductInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method OrderProductInterface[] findAll()
* @method OrderProductInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class OrderProductRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return OrderProductInterface::class;
}
}

+ 21
- 0
ShopBundle/Repository/OrderShopRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\OrderShopInterface;

/**
* @method OrderShopInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method OrderShopInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method OrderShopInterface[] findAll()
* @method OrderShopInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class OrderShopRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return OrderShopInterface::class;
}

}

+ 21
- 0
ShopBundle/Repository/OrderStatusHistoryRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\OrderStatusHistoryInterface;

/**
* @method OrderStatusHistoryInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method OrderStatusHistoryInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method OrderStatusHistoryInterface[] findAll()
* @method OrderStatusHistoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class OrderStatusHistoryRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return OrderStatusHistoryInterface::class;
}

}

+ 11
- 41
ShopBundle/Repository/PageRepository.php View File



namespace Lc\ShopBundle\Repository; namespace Lc\ShopBundle\Repository;


use App\Entity\Page;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Lc\ShopBundle\Repository\BaseRepository;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\PageInterface;


/** /**
* @method Page|null find($id, $lockMode = null, $lockVersion = null)
* @method Page|null findOneBy(array $criteria, array $orderBy = null)
* @method Page[] findAll()
* @method Page[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @method PageInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method PageInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method PageInterface[] findAll()
* @method PageInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class PageRepository extends BaseRepository
class PageRepository extends BaseRepository implements DefaultRepositoryInterface
{ {
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Page::class);
}
public function getInterfaceClass()
{
return PageInterface::class;
}


// /**
// * @return Page[] Returns an array of Page objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Page
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
} }

+ 21
- 0
ShopBundle/Repository/PointSaleDayInfoRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\PointSaleDayInfoInterface;

/**
* @method PointSaleDayInfoInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method PointSaleDayInfoInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method PointSaleDayInfoInterface[] findAll()
* @method PointSaleDayInfoInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class PointSaleDayInfoRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return PointSaleDayInfoInterface::class;
}

}

+ 5
- 38
ShopBundle/Repository/PointSaleRepository.php View File



namespace Lc\ShopBundle\Repository; namespace Lc\ShopBundle\Repository;


use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\PointSaleInterface; use Lc\ShopBundle\Context\PointSaleInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;



/** /**
* @method PointSaleInterface|null find($id, $lockMode = null, $lockVersion = null) * @method PointSaleInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method PointSaleInterface[] findAll() * @method PointSaleInterface[] findAll()
* @method PointSaleInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method PointSaleInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class PointSaleRepository extends BaseRepository
class PointSaleRepository extends BaseRepository implements DefaultRepositoryInterface
{ {
public function __construct(EntityManager $entityManager)
public function getInterfaceClass()
{ {

parent::__construct($entityManager, PointSaleInterface::class);
return PointSaleInterface::class;
} }




// /**
// * @return ProductCategory[] Returns an array of ProductCategory objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?ProductCategory
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
} }

+ 4
- 8
ShopBundle/Repository/ProductCategoryRepository.php View File



namespace Lc\ShopBundle\Repository; namespace Lc\ShopBundle\Repository;


use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Lc\ShopBundle\Context\GlobalParamInterface;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface; use Lc\ShopBundle\Context\ProductCategoryInterface;


/** /**
* @method ProductCategoryInterface[] findAll() * @method ProductCategoryInterface[] findAll()
* @method ProductCategoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method ProductCategoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class ProductCategoryRepository extends BaseRepository
class ProductCategoryRepository extends BaseRepository implements DefaultRepositoryInterface
{ {
protected $globalParam ;


public function __construct(EntityManager $entityManager, GlobalParamInterface $globalParam)
public function getInterfaceClass()
{ {
$this->globalParam = $globalParam ;
parent::__construct($entityManager, ProductCategoryInterface::class);
return ProductCategoryInterface::class;
} }


public static function adminQueryBuilderForTree(BaseRepository $e): QueryBuilder public static function adminQueryBuilderForTree(BaseRepository $e): QueryBuilder

+ 11
- 40
ShopBundle/Repository/ProductFamilyRepository.php View File



namespace Lc\ShopBundle\Repository; namespace Lc\ShopBundle\Repository;


use App\Entity\ProductFamily;
use Doctrine\ORM\EntityManager;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;


/** /**
* @method ProductFamily|null find($id, $lockMode = null, $lockVersion = null)
* @method ProductFamily|null findOneBy(array $criteria, array $orderBy = null)
* @method ProductFamily[] findAll()
* @method ProductFamily[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @method ProductFamilyInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method ProductFamilyInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method ProductFamilyInterface[] findAll()
* @method ProductFamilyInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class ProductFamilyRepository extends BaseRepository
class ProductFamilyRepository extends BaseRepository implements DefaultRepositoryInterface
{ {
public function __construct(EntityManager $registry)
{
parent::__construct($registry, ProductFamily::class);
}
public function getInterfaceClass()
{
return ProductFamilyInterface::class;
}



// /**
// * @return ProductFamily[] Returns an array of ProductFamily objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?ProductFamily
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
} }

+ 21
- 0
ShopBundle/Repository/ProductRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\ProductInterface;

/**
* @method ProductInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method ProductInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method ProductInterface[] findAll()
* @method ProductInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ProductRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return ProductInterface::class;
}

}

+ 21
- 0
ShopBundle/Repository/TaxRateRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\TaxRateInterface;

/**
* @method TaxRateInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method TaxRateInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method TaxRateInterface[] findAll()
* @method TaxRateInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class TaxRateRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return TaxRateInterface::class;
}

}

+ 21
- 0
ShopBundle/Repository/UnitRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\UnitInterface;

/**
* @method UnitInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method UnitInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method UnitInterface[] findAll()
* @method UnitInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class UnitRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return UnitInterface::class;
}

}

+ 21
- 0
ShopBundle/Repository/UserRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\UserInterface;

/**
* @method UserInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method UserInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method UserInterface[] findAll()
* @method UserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class UserRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return UserInterface::class;
}

}

+ 21
- 0
ShopBundle/Repository/VisitorRepository.php View File

<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\VisitorInterface;

/**
* @method VisitorInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method VisitorInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method VisitorInterface[] findAll()
* @method VisitorInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class VisitorRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return VisitorInterface::class;
}

}

Loading…
Cancel
Save