protected function _beforeEntityInsert(AnCommandContext $context)
    {
        if (!empty($this->couponCode)) {
            $coupon = $this->getService('repos:subscriptions.coupon')
                           ->find(array(
                             'code' => $this->couponCode,
                           ));

            if ($coupon) {
                $coupon->used();
            }
        }
    }
protected function _beforeEntityInsert(AnCommandContext $context)
    {
        if (!empty($this->couponCode)) {
            $coupon = $this->getService('repos:subscriptions.coupon')
                           ->find(array(
                             'code' => $this->couponCode,
                           ));

            if ($coupon) {
                $coupon->used();
            }
        }
    }
protected function _beforeEntityInsert ( AnCommandContext $ context ) { if ( ! empty ( $ this -> couponCode ) ) { $ coupon = $ this -> getService ( 'repos:subscriptions.coupon' ) -> find ( array ( 'code' => $ this -> couponCode , ) ) ; if ( $ coupon ) { $ coupon -> used ( ) ; } } }
Try to increment the coupong before inserting.

@param AnCommandContext $context
Try to increment the coupong before inserting .