/** * @param Customer $object * @return \Thelia\Form\BaseForm */ protected function hydrateObjectForm($object) { // Get default adress of the customer $address = $object->getDefaultAddress(); // Prepare the data that will hydrate the form $data = array('id' => $object->getId(), 'firstname' => $object->getFirstname(), 'lastname' => $object->getLastname(), 'email' => $object->getEmail(), 'title' => $object->getTitleId(), 'discount' => $object->getDiscount(), 'reseller' => $object->getReseller()); if ($address !== null) { $data['company'] = $address->getCompany(); $data['address1'] = $address->getAddress1(); $data['address2'] = $address->getAddress2(); $data['address3'] = $address->getAddress3(); $data['phone'] = $address->getPhone(); $data['cellphone'] = $address->getCellphone(); $data['zipcode'] = $address->getZipcode(); $data['city'] = $address->getCity(); $data['country'] = $address->getCountryId(); $data['state'] = $address->getStateId(); } // A loop is used in the template return $this->createForm(AdminForm::CUSTOMER_UPDATE, 'form', $data); }
/** * Send a message to the customer. * * @param string $messageCode * @param Customer $customer * @param array $messageParameters an array of (name => value) parameters that will be available in the message. */ public function sendEmailToCustomer($messageCode, $customer, $messageParameters = []) { // Always add the customer ID to the parameters $messageParameters['customer_id'] = $customer->getId(); $this->sendEmailMessage($messageCode, [ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName()], [$customer->getEmail() => $customer->getFirstname() . " " . $customer->getLastname()], $messageParameters, $customer->getCustomerLang()->getLocale()); }
/** * @param Customer $customer * @return CustomerUpdateForm */ protected function hydrateCustomerForm(Customer $customer) { // Get default adress of the customer $address = $customer->getDefaultAddress(); // Prepare the data that will hydrate the form $data = array('id' => $customer->getId(), 'firstname' => $customer->getFirstname(), 'lastname' => $customer->getLastname(), 'email' => $customer->getEmail(), 'title' => $customer->getTitleId(), 'discount' => $customer->getDiscount(), 'reseller' => $customer->getReseller()); if ($address !== null) { $data['company'] = $address->getCompany(); $data['address1'] = $address->getAddress1(); $data['address2'] = $address->getAddress2(); $data['address3'] = $address->getAddress3(); $data['phone'] = $address->getPhone(); $data['cellphone'] = $address->getCellphone(); $data['zipcode'] = $address->getZipcode(); $data['city'] = $address->getCity(); $data['country'] = $address->getCountryId(); } // A loop is used in the template return new CustomerUpdateForm($this->getRequest(), 'form', $data); }