/**
  * @param CustomerCustomerFamilyEvent $event
  */
 public function customerCustomerFamilyUpdate(CustomerCustomerFamilyEvent $event)
 {
     $customerCustomerFamily = CustomerCustomerFamilyQuery::create()->findOneByCustomerId($event->getCustomerId());
     if ($customerCustomerFamily === null) {
         $customerCustomerFamily = new CustomerCustomerFamily();
         $customerCustomerFamily->setCustomerId($event->getCustomerId());
     }
     $customerCustomerFamily->setCustomerFamilyId($event->getCustomerFamilyId())->setSiret($event->getSiret())->setVat($event->getVat())->save();
 }
 /**
  * @return mixed|\Thelia\Core\HttpFoundation\Response
  */
 public function customerUpdateAction()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('CustomerFamily'), AccessManager::UPDATE))) {
         return $response;
     }
     $error = "";
     $form = new CustomerCustomerFamilyForm($this->getRequest());
     try {
         $formValidate = $this->validateForm($form);
         $event = new CustomerCustomerFamilyEvent($formValidate->get('customer_id')->getData());
         $event->setCustomerFamilyId($formValidate->get('customer_family_id')->getData())->setSiret($formValidate->get('siret')->getData())->setVat($formValidate->get('vat')->getData());
         $this->dispatch(CustomerFamilyEvents::CUSTOMER_CUSTOMER_FAMILY_UPDATE, $event);
         $this->redirect(URL::getInstance()->absoluteUrl('/admin/customer/update?customer_id=' . $formValidate->get('customer_id')->getData()));
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $form->setErrorMessage($error);
     $this->getParserContext()->addForm($form)->setGeneralError($error);
     //Don't forget to fill the Customer form
     $customerId = $this->getRequest()->request->get('customer_customer_family_form')['customer_id'];
     if (null != ($customer = CustomerQuery::create()->findPk($customerId))) {
         $customerForm = $this->hydrateCustomerForm($customer);
         $this->getParserContext()->addForm($customerForm);
     }
     return $this->render('customer-edit', array('customer_id' => $this->getRequest()->request->get('customer_customer_family_form')['customer_id'], "order_creation_error" => Translator::getInstance()->trans($error, array(), CustomerFamily::MESSAGE_DOMAIN)));
 }