/** * Build a CouponInterface from its Model data contained in the DataBase * * @param Coupon $model Database data * * @return CouponInterface ready to use CouponInterface object instance */ public function buildCouponFromModel(Coupon $model) { $isCumulative = $model->getIsCumulative() == 1 ? true : false; $isRemovingPostage = $model->getIsRemovingPostage() == 1 ? true : false; if (!$this->container->has($model->getType())) { return false; } /** @var CouponInterface $couponManager*/ $couponManager = $this->container->get($model->getType()); $couponManager->set($this->facade, $model->getCode(), $model->getTitle(), $model->getShortDescription(), $model->getDescription(), $model->getEffects(), $isCumulative, $isRemovingPostage, $model->getIsAvailableOnSpecialOffers(), $model->getIsEnabled(), $model->getMaxUsage(), $model->getExpirationDate(), $model->getFreeShippingForCountries(), $model->getFreeShippingForModules(), $model->getPerCustomerUsageCount()); /** @var ConditionFactory $conditionFactory */ $conditionFactory = $this->container->get('thelia.condition.factory'); $conditions = $conditionFactory->unserializeConditionCollection($model->getSerializedConditions()); $couponManager->setConditions($conditions); return clone $couponManager; }