Browse Source

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

packProduct
Guillaume 3 years ago
parent
commit
109d73289e
5 changed files with 129 additions and 6 deletions
  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 View File

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\User\UserPointSaleInterface; use Lc\CaracoleBundle\Model\User\UserPointSaleInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
use App\Entity\File\File;


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
protected $userPointSales; protected $userPointSales;


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


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


return $this; 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 View File

namespace Lc\CaracoleBundle\Repository\Product; namespace Lc\CaracoleBundle\Repository\Product;


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


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

protected $isJoinProductFamilies = false;



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


public function filterIsParent(){
return $this->andWhere('.parent is NULL');
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 View File



namespace Lc\CaracoleBundle\Repository\Product; namespace Lc\CaracoleBundle\Repository\Product;


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


$this->query = $query; $this->query = $query;
} }


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

return $query->find(); 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 View File

<?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 View File

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

}

Loading…
Cancel
Save