Browse Source

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

feature/export_comptable
Guillaume 4 years ago
parent
commit
0262f582d8
1 changed files with 24 additions and 1 deletions
  1. +24
    -1
      ShopBundle/Repository/ReductionCartRepository.php

+ 24
- 1
ShopBundle/Repository/ReductionCartRepository.php View File

@@ -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…
Cancel
Save