public function updateAction($id) { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('CustomerFamily'), AccessManager::UPDATE))) { return $response; } $error = ""; $form = new CustomerFamilyUpdateForm($this->getRequest()); try { $formValidate = $this->validateForm($form); $customerFamily = CustomerFamilyQuery::create()->findPk($id); if ($customerFamily === null) { throw new \Exception("Customer Family not found by Id"); } $event = new CustomerFamilyEvent($customerFamily); $event->hydrateByForm($formValidate); $this->dispatch(CustomerFamilyEvents::CUSTOMER_FAMILY_UPDATE, $event); } catch (\Exception $e) { $error = $e->getMessage(); } $message = Translator::getInstance()->trans("Customer family was updated successfully", array(), CustomerFamily::MODULE_DOMAIN); return self::renderAdminConfig($form, $message, $error); }
/** * @param CustomerFamilyEvent $event */ public function delete(CustomerFamilyEvent $event) { $event->getCustomerFamily()->delete(); }