protected function feedCouponCreateOrUpdateEvent(Form $form, Coupon $model = null)
    {
        // Get the form field values
        $data = $form->getData();
        $serviceId = $data['type'];

        /** @var CouponInterface $coupon */
        $coupon = $this->container->get($serviceId);

        $couponEvent = new CouponCreateOrUpdateEvent(
            $data['code'],
            $serviceId,
            $data['title'],
            $coupon->getEffects($data),
            $data['shortDescription'],
            $data['description'],
            $data['isEnabled'],
            \DateTime::createFromFormat($this->getDefaultDateFormat(), $data['expirationDate']),
            $data['isAvailableOnSpecialOffers'],
            $data['isCumulative'],
            $data['isRemovingPostage'],
            $data['maxUsage'],
            $data['locale'],
            $data['freeShippingForCountries'],
            $data['freeShippingForModules'],
            $data['perCustomerUsageCount'],
            empty($data['startDate']) ? null : \DateTime::createFromFormat($this->getDefaultDateFormat(), $data['startDate'])
        );

        // If Update mode
        if (isset($model)) {
            $couponEvent->setCouponModel($model);
        }

        return $couponEvent;
    }
protected function feedCouponCreateOrUpdateEvent(Form $form, Coupon $model = null)
    {
        // Get the form field values
        $data = $form->getData();
        $serviceId = $data['type'];

        /** @var CouponInterface $coupon */
        $coupon = $this->container->get($serviceId);

        $couponEvent = new CouponCreateOrUpdateEvent(
            $data['code'],
            $serviceId,
            $data['title'],
            $coupon->getEffects($data),
            $data['shortDescription'],
            $data['description'],
            $data['isEnabled'],
            \DateTime::createFromFormat($this->getDefaultDateFormat(), $data['expirationDate']),
            $data['isAvailableOnSpecialOffers'],
            $data['isCumulative'],
            $data['isRemovingPostage'],
            $data['maxUsage'],
            $data['locale'],
            $data['freeShippingForCountries'],
            $data['freeShippingForModules'],
            $data['perCustomerUsageCount'],
            empty($data['startDate']) ? null : \DateTime::createFromFormat($this->getDefaultDateFormat(), $data['startDate'])
        );

        // If Update mode
        if (isset($model)) {
            $couponEvent->setCouponModel($model);
        }

        return $couponEvent;
    }
protected function feedCouponCreateOrUpdateEvent ( Form $ form , Coupon $ model = null ) { // Get the form field values $ data = $ form -> getData ( ) ; $ serviceId = $ data [ 'type' ] ; /** @var CouponInterface $coupon */ $ coupon = $ this -> container -> get ( $ serviceId ) ; $ couponEvent = new CouponCreateOrUpdateEvent ( $ data [ 'code' ] , $ serviceId , $ data [ 'title' ] , $ coupon -> getEffects ( $ data ) , $ data [ 'shortDescription' ] , $ data [ 'description' ] , $ data [ 'isEnabled' ] , \ DateTime :: createFromFormat ( $ this -> getDefaultDateFormat ( ) , $ data [ 'expirationDate' ] ) , $ data [ 'isAvailableOnSpecialOffers' ] , $ data [ 'isCumulative' ] , $ data [ 'isRemovingPostage' ] , $ data [ 'maxUsage' ] , $ data [ 'locale' ] , $ data [ 'freeShippingForCountries' ] , $ data [ 'freeShippingForModules' ] , $ data [ 'perCustomerUsageCount' ] , empty ( $ data [ 'startDate' ] ) ? null : \ DateTime :: createFromFormat ( $ this -> getDefaultDateFormat ( ) , $ data [ 'startDate' ] ) ) ; // If Update mode if ( isset ( $ model ) ) { $ couponEvent -> setCouponModel ( $ model ) ; } return $ couponEvent ; }
Feed the Coupon Create or Update event with the User inputs

@param Form   $form  Form containing user data
@param Coupon $model Model if in update mode

@return CouponCreateOrUpdateEvent
Feed the Coupon Create or Update event with the User inputs