Bläddra i källkod

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Guillaume 3 år sedan
förälder
incheckning
109d73289e
5 ändrade filer med 129 tillägg och 6 borttagningar
  1. +17
    -0
      Model/PointSale/PointSaleModel.php
  2. +28
    -3
      Repository/Product/ProductCategoryRepositoryQuery.php
  3. +36
    -3
      Repository/Product/ProductCategoryStore.php
  4. +26
    -0
      Repository/StatusRepositoryQueryTrait.php
  5. +22
    -0
      Repository/TreeRepositoryQueryTrait.php

+ 17
- 0
Model/PointSale/PointSaleModel.php Visa fil

@@ -12,6 +12,7 @@ use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\User\UserPointSaleInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
use App\Entity\File\File;

/**
* @ORM\MappedSuperclass()
@@ -43,6 +44,10 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip
*/
protected $userPointSales;

/**
* @ORM\ManyToOne(targetEntity=File::class, cascade={"persist", "remove"})
*/
protected $image;

public function __construct()
{
@@ -140,4 +145,16 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip

return $this;
}

public function getImage(): ?File
{
return $this->image;
}

public function setImage(?File $image): self
{
$this->image = $image;

return $this;
}
}

+ 28
- 3
Repository/Product/ProductCategoryRepositoryQuery.php Visa fil

@@ -3,21 +3,46 @@
namespace Lc\CaracoleBundle\Repository\Product;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\TreeRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
{
use SectionRepositoryQueryTrait;
use StatusRepositoryQueryTrait;
use TreeRepositoryQueryTrait;

protected $isJoinProductFamilies = false;


public function __construct(ProductCategoryRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}

public function filterIsParent(){
return $this->andWhere('.parent is NULL');
public function joinProductFamilies(): self
{
if (!$this->isJoinProductFamilies) {
$this->isJoinProductFamilies = true;

return $this
->innerJoin('.productFamilies', 'pf');
}

return $this;
}
public function hasProductFamilyOnline(): self
{
$this->joinProductFamilies();

return $this->andWhere('pf.status = 1');
}

public function filterByCurrentDay(): self
{
return $this->andWhere('e.displaySpecificDay IS NULL OR e.displaySpecificDay = :dayToday')
->setParameter('dayToday', date('N'));
}
}

+ 36
- 3
Repository/Product/ProductCategoryStore.php Visa fil

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Repository\Product;

use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;

@@ -16,13 +17,45 @@ class ProductCategoryStore extends AbstractStore
$this->query = $query;
}

public function getParents(){
public function getParents()
{
$query = $this->query->create();
if($this->section) {
if ($this->section) {
$query->filterBySection($this->section);
}
$query->filterIsParent();

return $query->find();
}

//findAllByParent
public function getByParent(
ProductCategoryInterface $parentCategory,
bool $withOffline = false,
bool $withEmptyCategories = true,
bool $filterBySpecificDay = false
): array {

$query = $this->query->create();
$query->filterByParent($parentCategory);

if ($withOffline) {
$query->filterIsOnlineAndOffline();
} else {
$query->filterIsOnline();
}

if (!$withEmptyCategories) {
$query->hasProductFamilyOnline();
}

if ($filterBySpecificDay) {
$query->filterBySpecificDay();
}

$query->orderBy('position', 'asc');

return $query->find();
}

}

+ 26
- 0
Repository/StatusRepositoryQueryTrait.php Visa fil

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

namespace Lc\CaracoleBundle\Repository;

trait StatusRepositoryQueryTrait
{
public function filterByStatus(int $status):self
{
return $this->andWhere('.status = :status')->setParameter(':status', $status);
}

public function filterIsOffline():self
{
return $this->andWhere('.status = :status')->setParameter(':status', 0);
}

public function filterIsOnline():self
{
return $this->andWhere('.status = :status')->setParameter(':status', 1);
}

public function filterIsOnlineAndOffline():self
{
return $this->andWhere('.status >= 0');
}
}

+ 22
- 0
Repository/TreeRepositoryQueryTrait.php Visa fil

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

namespace Lc\CaracoleBundle\Repository;


use Lc\SovBundle\Doctrine\EntityInterface;

trait TreeRepositoryQueryTrait
{
public function filterIsParent(){
return $this->andWhere('.parent is NULL');
}

public function filterIsChildren(){
return $this->andWhere('.parent is NOT NULL');
}

public function filterByParent(EntityInterface $parent){
return $this->andWhere('.parent = :parent')->setParameter('parent', $parent);
}

}

Laddar…
Avbryt
Spara