don't save the currentCoupons in a property. Retrieve them from the

session
This commit is contained in:
Manuel Raynaud
2014-01-10 11:20:57 +01:00
parent 75007cc6c5
commit 149a943a0e

View File

@@ -43,9 +43,6 @@ class CouponManager
/** @var ContainerInterface Service Container */ /** @var ContainerInterface Service Container */
protected $container = null; protected $container = null;
/** @var array CouponInterface to process*/
protected $coupons = array();
/** @var array Available Coupons (Services) */ /** @var array Available Coupons (Services) */
protected $availableCoupons = array(); protected $availableCoupons = array();
@@ -61,7 +58,6 @@ class CouponManager
{ {
$this->container = $container; $this->container = $container;
$this->facade = $container->get('thelia.facade'); $this->facade = $container->get('thelia.facade');
$this->coupons = $this->facade->getCurrentCoupons();
} }
@@ -74,9 +70,9 @@ class CouponManager
public function getDiscount() public function getDiscount()
{ {
$discount = 0.00; $discount = 0.00;
$coupons = $this->facade->getCurrentCoupons();
if (count($this->coupons) > 0) { if (count($coupons) > 0) {
$couponsKept = $this->sortCoupons($this->coupons); $couponsKept = $this->sortCoupons($coupons);
$discount = $this->getEffect($couponsKept); $discount = $this->getEffect($couponsKept);
@@ -96,11 +92,12 @@ class CouponManager
*/ */
public function isCouponRemovingPostage() public function isCouponRemovingPostage()
{ {
if (count($this->coupons) == 0) { $coupons = $this->facade->getCurrentCoupons();
if (count($coupons) == 0) {
return false; return false;
} }
$couponsKept = $this->sortCoupons($this->coupons); $couponsKept = $this->sortCoupons($coupons);
/** @var CouponInterface $coupon */ /** @var CouponInterface $coupon */
foreach ($couponsKept as $coupon) { foreach ($couponsKept as $coupon) {