Create form for editing customer

@param \Slashworks\AppBundle\Model\Customer $oCustomer

@return \Symfony\Component\Form\Form
431252
private function createEditForm(Customer $oCustomer)
        {

            $oForm = $this->createForm(new CustomerType(array("language" => $this->get('request')->getLocale())), $oCustomer, array(
                'action' => $this->generateUrl('backend_system_customer_update', array('id' => $oCustomer->getId())),
                'method' => 'PUT',
            ));

            $oForm->add('submit', 'submit', array('label' => 'Update'));

            return $oForm;
        }
283803
public function createAction()
    {
        if (! $this->getSecurityContext()->hasCustomerUser()) {
            $customerCreation = $this->createForm(FrontForm::CUSTOMER_CREATE);

            try {
                $form = $this->validateForm($customerCreation, "post");

                $customerCreateEvent = $this->createEventInstance($form->getData());

                $this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent);

                $newCustomer = $customerCreateEvent->getCustomer();

                // Newsletter
                if (true === $form->get('newsletter')->getData()) {
                    $newsletterEmail = $newCustomer->getEmail();
                    $nlEvent = new NewsletterEvent(
                        $newsletterEmail,
                        $this->getRequest()->getSession()->getLang()->getLocale()
                    );
                    $nlEvent->setFirstname($newCustomer->getFirstname());
                    $nlEvent->setLastname($newCustomer->getLastname());

                    // Security : Check if this new Email address already exist
                    if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterEmail)) {
                        $nlEvent->setId($newsletter->getId());
                        $this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent);
                    } else {
                        $this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent);
                    }
                }

                if (ConfigQuery::isCustomerEmailConfirmationEnable() && ! $newCustomer->getEnable()) {
                    $response = $this->generateRedirectFromRoute('customer.login.view');
                } else {
                    $this->processLogin($customerCreateEvent->getCustomer());

                    $cart = $this->getSession()->getSessionCart($this->getDispatcher());
                    if ($cart->getCartItems()->count() > 0) {
                        $response = $this->generateRedirectFromRoute('cart.view');
                    } else {
                        $response = $this->generateSuccessRedirect($customerCreation);
                    }
                }

                return $response;
            } catch (FormValidationException $e) {
                $message = $this->getTranslator()->trans(
                    "Please check your input: %s",
                    [
                        '%s' => $e->getMessage()
                    ],
                    Front::MESSAGE_DOMAIN
                );
            } catch (\Exception $e) {
                $message = $this->getTranslator()->trans(
                    "Sorry, an error occured: %s",
                    [
                        '%s' => $e->getMessage()
                    ],
                    Front::MESSAGE_DOMAIN
                );
            }

            Tlog::getInstance()->error(
                sprintf(
                    "Error during customer creation process : %s. Exception was %s",
                    $message,
                    $e->getMessage()
                )
            );

            $customerCreation->setErrorMessage($message);

            $this->getParserContext()
                ->addForm($customerCreation)
                ->setGeneralError($message)
            ;

            // Redirect to error URL if defined
            if ($customerCreation->hasErrorUrl()) {
                return $this->generateErrorRedirect($customerCreation);
            }
        }
    }
914716
protected function createContactForm()
    {
        $form = UserDefinedForm::create(array(
            'Title' => 'Contact',
            'URLSegment' => 'contact',
            'Content' => '<p>$UserDefinedForm</p>',
            'SubmitButtonText' => 'Submit',
            'ClearButtonText' => 'Clear',
            'OnCompleteMessage' => "<p>Thanks, we've received your submission and will be in touch shortly.</p>",
            'EnableLiveValidation' => true
        ));

        $form->write();

        // Add form fields
        $fields = array(
            EditableFormStep::create([
                'Title' => _t(
                    'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.TITLE_FIRST',
                    'First Page'
                )
            ]),
            EditableTextField::create([
                'Title' => 'Name',
                'Required' => true,
                'RightTitle' => 'Please enter your first and last name'
            ]),
            EditableEmailField::create([
                'Title' => Email::class,
                'Required' => true,
                'Placeholder' => 'example@example.com'
            ]),
            EditableTextField::create([
                'Title' => 'Subject'
            ]),
            EditableTextField::create([
                'Title' => 'Message',
                'Required' => true,
                'Rows' => 5
            ])
        );

        foreach ($fields as $field) {
            $field->write();
            $form->Fields()->add($field);
            $field->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
        }

        $form->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
        $form->flushCache();

        $this->output(' + Created "contact" UserDefinedForm page');

        return $this;
    }
585633
public function newAction()
        {
            $oUser = new User();
            $form   = $this->createCreateForm($oUser);

            return $this->render('SlashworksBackendBundle:User:new.html.twig', array(
                'entity' => $oUser,
                'form'   => $form->createView(),
            ));
        }
1220185
public function afterCreate(\Magento\Sales\Api\OrderCustomerManagementInterface $subject, $customer)
    {
        //New Automation enrolment to queue
        $this->automation->newCustomerAutomation($customer);

        return $customer;
    }
136876
public function newAction()
        {

            $oCustomer = new Customer();
            $form      = $this->createCreateForm($oCustomer);

            return $this->render('SlashworksAppBundle:Customer:new.html.twig', array(
                'entity' => $oCustomer,
                'form'   => $form->createView(),
            ));
        }
370221
public function setContactData($customer)
    {
        $this->model = $customer;
        $this->setReviewCollection();
        parent::setContactData($customer);

        return $this;
    }
755778
protected function createComponentSignInForm(): Form
	{
		$form = $this->formFactory->create();
		$form->addProtection();

		$form->addText('username', 'cms.user.username')
			->setAttribute('autofocus', true)
			->setRequired();

		$form->addPassword('password', 'cms.user.password')
			->setRequired();

		$form->addCheckbox('remember', 'cms.user.staySignedIn');

		$form->addSubmit('send', 'cms.user.signIn');

		$form->onSuccess[] = [$this, 'signInFormSucceeded'];

		return $form;
	}
1076865
public function setCustomer(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\Customer $customer = null)
    {
        $this->customer = $customer;

        return $this;
    }
1026025
public function edit($user)
    {
        $user = User::find($user);
        if (!$user) {
            return redirect_to_resource();
        }

        $roles = Role::getAllLists();

        return $this->view('titan::clients.create_edit')->with('item', $user)->with('roles', $roles);
    }
700320
public function editAction()
    {
        $form = $this->getEditForm();
        $entity = $form->getObject();
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getPost()->toArray();
            $entityManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
            $hydrator = new DoctrineHydrator($entityManager);
            $hydrator->hydrate($data, $entity);

            if ($form->isValid()) {
                $objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
                $objectManager->persist($entity);
                $objectManager->flush();
                $controller = explode('/', $this->getRequest()->getUri()->getPath())[2];
                if (!$this->getRequest()->isXmlHttpRequest()) {
                    return $this->redirect()->toRoute(null, ['controller' => $controller]);
                }
                return;
            } else {
                $this->getResponse()->setStatusCode(400);
            }
        }
        $viewModel = $this->getViewModel();
        $viewModel->setTerminal($this->getRequest()->isXmlHttpRequest());

        return $viewModel->setVariables(['form' => $form]);
    }
87808
public function ExecutePayment(TdbShopOrder &$oOrder, $sMessageConsumer = '')
    {
        $bPaymentOk = parent::ExecutePayment($oOrder);
        if ($bPaymentOk) {
            TdbShopPaymentHandler::SetExecutePaymentInterrupt(true);
            $bPaymentOk = $this->ExecuteIPaymentCall($oOrder);
        }

        return $bPaymentOk;
    }
666764
public function createRecipient()
    {
        $result = count( $this->recipients );
        $this->recipients[$result] = new ezcMailHeadersHolder();
        return $result;
    }
856750
public function CustomerForm()
    {
        // If no estimate found, generate error
        if (!$this->hasEstimate()) {
            return $this->redirect($this->Link("noestimate"));
        }

        $session = $this
            ->getRequest()
            ->getSession();

        $member = Security::getCurrentUser();
        $contact = ($member) ? $member->Contact() : $member;

        $form = CustomerDetailsForm::create(
            $this,
            'CustomerForm',
            $this->getEstimate()
        );

        $data = $session->get("Checkout." . $form->FormName() . ".data");
        
        if (is_array($data)) {
            $form->loadDataFrom($data);
        } elseif ($contact) {
            // Fill email, phone, etc
            $form->loadDataFrom($contact);
            
            // Then fill with Address info
            if($contact->DefaultLocation()) {
                $form->loadDataFrom($contact->DefaultLocation());
            }
        }

        $this->extend("updateCustomerForm", $form);

        return $form;
    }
167175
private function createEditForm(License $oLicense)
        {

            $oForm = $this->createForm(new LicenseType(), $oLicense, array(
                'action' => $this->generateUrl('license_update', array('id' => $oLicense->getId())),
                'method' => 'PUT',
            ));

            $oForm->add('submit', 'submit', array('label' => 'Update'));

            return $oForm;
        }
1288789
private function _handleLogoUpload(Request &$request, Customer &$oCustomer)
        {

            $sLogoPath = "";

            /** @var FileBag $t */
            $oFiles      = $request->files;
            $aFiles      = $oFiles->get("slashworks_appbundle_customer");
            $sUploadPath = __DIR__ . "/../../../../web/files/customers";

            if (isset($aFiles['logo'])) {
                if (!empty($aFiles['logo'])) {
                    /** @var UploadedFile $oUploadedFile */
                    $oUploadedFile = $aFiles['logo'];

                    $sUniqId   = sha1(uniqid(mt_rand(), true));
                    $sFileName = $sUniqId . '.' . $oUploadedFile->guessExtension();

                    $oUploadedFile->move($sUploadPath, $sFileName);
                    $sLogoPath = $sFileName;
                }
            }


            return $sLogoPath;
        }
335936
public function createCustomer()
    {
        $data = [
            "email" => request()->email,
            "first_name" => request()->fname,
            "last_name" => request()->lname,
            "phone" => request()->phone,
            "metadata" => request()->additional_info /* key => value pairs array */

        ];

        $this->setRequestOptions();
        return $this->setHttpResponse('/customer', 'POST', $data)->getResponse();
    }