Selaa lähdekoodia

Refactoring Repository & AdminController

reduction
Fab 4 vuotta sitten
vanhempi
commit
65073aee7e
36 muutettua tiedostoa jossa 714 lisäystä ja 399 poistoa
  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 Näytä tiedosto

@@ -0,0 +1,15 @@
<?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 Näytä tiedosto

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context ;

interface FilterMultipleMerchantsInterface
{

}

+ 6
- 1
ShopBundle/Context/GlobalParamInterface.php Näytä tiedosto

@@ -4,5 +4,10 @@ namespace Lc\ShopBundle\Context ;

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 Näytä tiedosto

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context;

interface SluggableInterface
{

}

+ 54
- 146
ShopBundle/Controller/Admin/AdminController.php Näytä tiedosto

@@ -2,23 +2,17 @@

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\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\MerchantConfigInterface;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TreeInterface;
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 Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
@@ -30,21 +24,20 @@ class AdminController extends EasyAdminController
{
protected $security;
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->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()
{
$id = $this->request->query->get('id');
@@ -54,7 +47,23 @@ class AdminController extends EasyAdminController
'action' => 'edit',
'entity' => $entity,
'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)
@@ -73,8 +82,9 @@ class AdminController extends EasyAdminController

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

@@ -82,18 +92,18 @@ class AdminController extends EasyAdminController

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)
{
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter) ;
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter);
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter);
$this->commonQueryFilter($entityClass, $queryBuilder) ;
return $queryBuilder ;
$this->commonQueryFilter($entityClass, $queryBuilder);
return $queryBuilder;
}


@@ -121,108 +131,7 @@ class AdminController extends EasyAdminController
];
}

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()
{
@@ -299,7 +208,7 @@ class AdminController extends EasyAdminController

}
//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++;
$offlineEntity->setPosition($latsPos);
$this->em->persist($offlineEntity);
@@ -347,17 +256,17 @@ class AdminController extends EasyAdminController
// @TODO : À passer dans le controller de App
$formBuilder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
$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(
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(),
@@ -365,18 +274,17 @@ class AdminController extends EasyAdminController
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false,
'placeholder' => '--',
'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'],
)

+ 10
- 1
ShopBundle/Controller/ApiController.php Näytä tiedosto

@@ -4,9 +4,11 @@ namespace Lc\ShopBundle\Controller;

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

class ApiController extends AbstractController
@@ -23,6 +25,13 @@ class ApiController extends AbstractController

public function getEntity($entity, $id)
{

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



if($entity == 'product'){
$repo = $this->em->getRepository(ProductInterface::class);
$data = $repo->find($id);
@@ -36,7 +45,7 @@ class ApiController extends AbstractController
);
}

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

}

+ 99
- 0
ShopBundle/EventSubscriber/EditEventSubscriber.php Näytä tiedosto

@@ -0,0 +1,99 @@
<?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 Näytä tiedosto

@@ -3,6 +3,7 @@
namespace Lc\ShopBundle\EventSubscriber;

use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -10,7 +11,7 @@ use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\Security\Core\Security;


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

@@ -40,32 +41,24 @@ class EasyAdminSubscriber implements EventSubscriberInterface
$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 Näytä tiedosto

@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Model;

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

use StatusTrait;

use SluggableTrait;

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

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

/**
* @ORM\Column(type="text", nullable=true)
@@ -56,17 +54,7 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
return $this;
}

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

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

return $this;
}

public function getDescription(): ?string
{

+ 2
- 0
ShopBundle/Model/AbstractEntity.php Näytä tiedosto

@@ -27,12 +27,14 @@ abstract class AbstractEntity
protected $updatedAt;

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

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

+ 3
- 3
ShopBundle/Model/Merchant.php Näytä tiedosto

@@ -25,7 +25,7 @@ abstract class Merchant extends AbstractDocumentEntity
protected $taxRate;

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

@@ -48,7 +48,7 @@ abstract class Merchant extends AbstractDocumentEntity
/**
* @ORM\OneToMany(targetEntity="App\Entity\ProductCategory", mappedBy="merchant", orphanRemoval=true)
*/
private $productCategories;
protected $productCategories;

public function __construct()
{
@@ -227,4 +227,4 @@ abstract class Merchant extends AbstractDocumentEntity

return $this;
}
}
}

+ 10
- 9
ShopBundle/Model/PointSale.php Näytä tiedosto

@@ -5,16 +5,17 @@ namespace Lc\ShopBundle\Model;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;

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

/**
* @ORM\Column(type="string", length=63, nullable=true)
@@ -39,7 +40,7 @@ abstract class PointSale extends AbstractDocumentEntity

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

@@ -51,15 +52,15 @@ abstract class PointSale extends AbstractDocumentEntity
/**
* @return Collection|Merchant[]
*/
public function getMerchant(): Collection
public function getMerchants(): Collection
{
return $this->merchant;
return $this->merchants;
}

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

return $this;
@@ -67,8 +68,8 @@ abstract class PointSale extends AbstractDocumentEntity

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;

+ 2
- 1
ShopBundle/Model/ProductCategory.php Näytä tiedosto

@@ -7,12 +7,13 @@ use App\Entity\ProductFamily;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\TreeInterface;

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

/**

+ 26
- 0
ShopBundle/Model/SluggableTrait.php Näytä tiedosto

@@ -0,0 +1,26 @@
<?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 Näytä tiedosto

@@ -0,0 +1,51 @@
<?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 Näytä tiedosto

@@ -5,36 +5,25 @@ namespace Lc\ShopBundle\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface;
use Doctrine\ORM\EntityManager;
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;

class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface
{
public $globalParam;

/**
* @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)
{
@@ -43,15 +32,48 @@ class BaseRepository extends EntityRepository implements ServiceEntityRepository
->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 Näytä tiedosto

@@ -0,0 +1,20 @@
<?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 Näytä tiedosto

@@ -0,0 +1,20 @@
<?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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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 Näytä tiedosto

@@ -0,0 +1,23 @@
<?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 Näytä tiedosto

@@ -0,0 +1,23 @@
<?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 Näytä tiedosto

@@ -6,6 +6,7 @@ use App\Entity\MerchantConfig;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManager;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\MerchantConfigInterface;
use Lc\ShopBundle\Repository\BaseRepository;
use Symfony\Component\Security\Core\Security;
@@ -15,51 +16,10 @@ use Symfony\Component\Security\Core\Security;
* @method MerchantConfig|null findOneBy(array $criteria, array $orderBy = 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 Näytä tiedosto

@@ -0,0 +1,20 @@
<?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 Näytä tiedosto

@@ -0,0 +1,20 @@
<?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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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 Näytä tiedosto

@@ -2,50 +2,20 @@

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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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 Näytä tiedosto

@@ -2,11 +2,9 @@

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\ProductCategoryInterface;


/**
* @method PointSaleInterface|null find($id, $lockMode = null, $lockVersion = null)
@@ -14,42 +12,11 @@ use Lc\ShopBundle\Context\ProductCategoryInterface;
* @method PointSaleInterface[] findAll()
* @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 Näytä tiedosto

@@ -2,10 +2,8 @@

namespace Lc\ShopBundle\Repository;

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

/**
@@ -14,14 +12,12 @@ use Lc\ShopBundle\Context\ProductCategoryInterface;
* @method ProductCategoryInterface[] findAll()
* @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

+ 11
- 40
ShopBundle/Repository/ProductFamilyRepository.php Näytä tiedosto

@@ -2,49 +2,20 @@

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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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 Näytä tiedosto

@@ -0,0 +1,21 @@
<?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…
Peruuta
Tallenna