Преглед на файлове

ReductionCart : récupération des ReductionCart pour un user donné

feature/export_comptable
Guillaume преди 4 години
родител
ревизия
0262f582d8
променени са 1 файла, в които са добавени 24 реда и са изтрити 1 реда
  1. +24
    -1
      ShopBundle/Repository/ReductionCartRepository.php

+ 24
- 1
ShopBundle/Repository/ReductionCartRepository.php Целия файл

@@ -2,7 +2,10 @@

namespace Lc\ShopBundle\Repository;

use Doctrine\ORM\EntityManager;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;

/**
@@ -13,6 +16,14 @@ use Lc\ShopBundle\Context\ReductionCartInterface;
*/
class ReductionCartRepository extends BaseRepository implements DefaultRepositoryInterface
{
protected $orderUtils ;

public function __construct(EntityManager $entityManager, MerchantUtilsInterface $merchantUtils, OrderUtilsInterface $orderUtils)
{
parent::__construct($entityManager, $merchantUtils);
$this->orderUtils = $orderUtils ;
}

public function getInterfaceClass()
{
return ReductionCartInterface::class;
@@ -49,8 +60,20 @@ class ReductionCartRepository extends BaseRepository implements DefaultRepositor
$query->andWhere('e.status = 1');

return $query->getQuery()->getResult();

}

public function findAllAvailableForUser($user)
{
$reductionCarts = $this->findAll() ;

$reductionCartsArray = [] ;
foreach($reductionCarts as $reductionCart) {
if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user)
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user)) {
$reductionCartsArray[] = $reductionCart ;
}
}

return $reductionCartsArray ;
}
}

Loading…
Отказ
Запис