public function updateRule(FreeShippingUpdateEvent $event)
 {
     $areaId = $event->getArea();
     $freeShippingArea = FreeShippingQuery::create()->findOneByAreaId($areaId);
     if (null === $freeShippingArea || $freeShippingArea->getAmount() !== $event->getAmount()) {
         $id = $event->getRuleId();
         if (null !== ($freeShipping = FreeShippingQuery::create()->findPk($id))) {
             $freeShipping->setDispatcher($event->getDispatcher());
             $freeShipping->setAreaId($event->getArea())->setAmount($event->getAmount())->save();
             $event->setRule($freeShipping);
         }
     } else {
         $area = AreaQuery::create()->findOneById($areaId);
         throw new \Exception(sprintf("A free shipping rule already exists for the '%s' area", $area->getName()));
     }
 }
 /**
  * Creates the update event with the provided form data
  *
  * @param unknown $formData
  */
 protected function getUpdateEvent($formData)
 {
     $freeShippingUpdateEvent = new FreeShippingUpdateEvent($formData['id']);
     $freeShippingUpdateEvent->setArea($formData['area'])->setAmount($formData['amount']);
     return $freeShippingUpdateEvent;
 }