Build the Body ot the Request and add it to $this->document
195122
protected function build()
    {
        $operation = $this->buildOperation('AcceptPayment');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        $tid = $this->document->createElement('tid', $this->tid);
        $operation->appendChild($tid);

        $pType = $this->document->createElement('pType', $this->pType);
        $operation->appendChild($pType);


        $payment = $this->document->createElement('payment');
        $payment->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:type', 'etp:Payment' . $this->pType);
        $payment = $operation->appendChild($payment);

        $this->appendArray($payment, $this->payment);

        $this->appendArray($operation, $this->additional);
    }
1010977
public function createBody()
    {
        $body = '';
        //Create unique IDs and preset boundaries
        $this->uniqueid = $this->generateId();
        $this->boundary[1] = 'b1_' . $this->uniqueid;
        $this->boundary[2] = 'b2_' . $this->uniqueid;
        $this->boundary[3] = 'b3_' . $this->uniqueid;

        if ($this->sign_key_file) {
            $body .= $this->getMailMIME() . static::$LE;
        }

        $this->setWordWrap();

        $bodyEncoding = $this->Encoding;
        $bodyCharSet = $this->CharSet;
        //Can we do a 7-bit downgrade?
        if (static::ENCODING_8BIT == $bodyEncoding and !$this->has8bitChars($this->Body)) {
            $bodyEncoding = static::ENCODING_7BIT;
            //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
            $bodyCharSet = 'us-ascii';
        }
        //If lines are too long, and we're not already using an encoding that will shorten them,
        //change to quoted-printable transfer encoding for the body part only
        if (static::ENCODING_BASE64 != $this->Encoding and static::hasLineLongerThanMax($this->Body)) {
            $bodyEncoding = static::ENCODING_QUOTED_PRINTABLE;
        }

        $altBodyEncoding = $this->Encoding;
        $altBodyCharSet = $this->CharSet;
        //Can we do a 7-bit downgrade?
        if (static::ENCODING_8BIT == $altBodyEncoding and !$this->has8bitChars($this->AltBody)) {
            $altBodyEncoding = static::ENCODING_7BIT;
            //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
            $altBodyCharSet = 'us-ascii';
        }
        //If lines are too long, and we're not already using an encoding that will shorten them,
        //change to quoted-printable transfer encoding for the alt body part only
        if (static::ENCODING_BASE64 != $altBodyEncoding and static::hasLineLongerThanMax($this->AltBody)) {
            $altBodyEncoding = static::ENCODING_QUOTED_PRINTABLE;
        }
        //Use this as a preamble in all multipart message types
        $mimepre = 'This is a multi-part message in MIME format.' . static::$LE;
        switch ($this->message_type) {
            case 'inline':
                $body .= $mimepre;
                $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('inline', $this->boundary[1]);
                break;
            case 'attach':
                $body .= $mimepre;
                $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('attachment', $this->boundary[1]);
                break;
            case 'inline_attach':
                $body .= $mimepre;
                $body .= $this->textLine('--' . $this->boundary[1]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[2] . '";');
                $body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('inline', $this->boundary[2]);
                $body .= static::$LE;
                $body .= $this->attachAll('attachment', $this->boundary[1]);
                break;
            case 'alt':
                $body .= $mimepre;
                $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
                $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
                $body .= static::$LE;
                $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                if (!empty($this->Ical)) {
                    $body .= $this->getBoundary($this->boundary[1], '', static::CONTENT_TYPE_TEXT_CALENDAR . '; method=REQUEST', '');
                    $body .= $this->encodeString($this->Ical, $this->Encoding);
                    $body .= static::$LE;
                }
                $body .= $this->endBoundary($this->boundary[1]);
                break;
            case 'alt_inline':
                $body .= $mimepre;
                $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
                $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
                $body .= static::$LE;
                $body .= $this->textLine('--' . $this->boundary[1]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[2] . '";');
                $body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('inline', $this->boundary[2]);
                $body .= static::$LE;
                $body .= $this->endBoundary($this->boundary[1]);
                break;
            case 'alt_attach':
                $body .= $mimepre;
                $body .= $this->textLine('--' . $this->boundary[1]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[2] . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
                $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
                $body .= static::$LE;
                $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                if (!empty($this->Ical)) {
                    $body .= $this->getBoundary($this->boundary[2], '', static::CONTENT_TYPE_TEXT_CALENDAR . '; method=REQUEST', '');
                    $body .= $this->encodeString($this->Ical, $this->Encoding);
                }
                $body .= $this->endBoundary($this->boundary[2]);
                $body .= static::$LE;
                $body .= $this->attachAll('attachment', $this->boundary[1]);
                break;
            case 'alt_inline_attach':
                $body .= $mimepre;
                $body .= $this->textLine('--' . $this->boundary[1]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[2] . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
                $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
                $body .= static::$LE;
                $body .= $this->textLine('--' . $this->boundary[2]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[3] . '";');
                $body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('inline', $this->boundary[3]);
                $body .= static::$LE;
                $body .= $this->endBoundary($this->boundary[2]);
                $body .= static::$LE;
                $body .= $this->attachAll('attachment', $this->boundary[1]);
                break;
            default:
                // Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types
                //Reset the `Encoding` property in case we changed it for line length reasons
                $this->Encoding = $bodyEncoding;
                $body .= $this->encodeString($this->Body, $this->Encoding);
                break;
        }

        if ($this->isError()) {
            $body = '';
            if ($this->exceptions) {
                throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);
            }
        } elseif ($this->sign_key_file) {
            try {
                if (!defined('PKCS7_TEXT')) {
                    throw new Exception($this->lang('extension_missing') . 'openssl');
                }
                $file = fopen('php://temp', 'rb+');
                $signed = fopen('php://temp', 'rb+');
                fwrite($file, $body);

                //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
                if (empty($this->sign_extracerts_file)) {
                    $sign = @openssl_pkcs7_sign(
                        $file,
                        $signed,
                        'file://' . realpath($this->sign_cert_file),
                        ['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
                        []
                    );
                } else {
                    $sign = @openssl_pkcs7_sign(
                        $file,
                        $signed,
                        'file://' . realpath($this->sign_cert_file),
                        ['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
                        [],
                        PKCS7_DETACHED,
                        $this->sign_extracerts_file
                    );
                }
                fclose($file);
                if ($sign) {
                    $body = file_get_contents($signed);
                    fclose($signed);
                    //The message returned by openssl contains both headers and body, so need to split them up
                    $parts = explode("\n\n", $body, 2);
                    $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE;
                    $body = $parts[1];
                } else {
                    fclose($signed);
                    throw new Exception($this->lang('signing') . openssl_error_string());
                }
            } catch (Exception $exc) {
                $body = '';
                if ($this->exceptions) {
                    throw $exc;
                }
            }
        }

        return $body;
    }
408594
protected function build()
    {
        $mail = clone $this;
        $mail->setHeader('Message-ID', $this->getRandomId());

        $cursor = $mail;
        if ($mail->attachments) {
            $tmp = $cursor->setContentType('multipart/mixed');
            $cursor = $cursor->addPart();
            foreach ($mail->attachments as $value) {
                $tmp->addPart($value);
            }
        }

        if ($mail->htmlBody !== '') {
            $tmp = $cursor->setContentType('multipart/alternative');
            $cursor = $cursor->addPart();
            $alt = $tmp->addPart();
            if ($mail->inlines) {
                $tmp = $alt->setContentType('multipart/related');
                $alt = $alt->addPart();
                foreach ($mail->inlines as $value) {
                    $tmp->addPart($value);
                }
            }
            $alt->setContentType('text/html', 'UTF-8')
                ->setEncoding(\preg_match('#[^\n]{990}#', $mail->htmlBody)
                    ? self::ENCODING_QUOTED_PRINTABLE
                    : (\preg_match('#[\x80-\xFF]#', $mail->htmlBody) ? self::ENCODING_8BIT : self::ENCODING_7BIT))
                ->setBody($mail->htmlBody);
        }

        $text = $mail->getBody();
        $mail->setBody('');
        $cursor->setContentType('text/plain', 'UTF-8')
            ->setEncoding(\preg_match('#[^\n]{990}#', $text)
                ? self::ENCODING_QUOTED_PRINTABLE
                : (\preg_match('#[\x80-\xFF]#', $text) ? self::ENCODING_8BIT : self::ENCODING_7BIT))
            ->setBody($text);

        return $mail;
    }
694949
public function build(): GetResponseBodyRequest
	{
		$instance = new GetResponseBodyRequest();
		if ($this->requestId === null) {
			throw new BuilderException('Property [requestId] is required.');
		}
		$instance->requestId = $this->requestId;
		return $instance;
	}
579862
protected function build()
    {
        $content = '';
        if (isset($this->parameters) && is_array($this->parameters)) {
            $content = http_build_query($this->parameters);
        }
        if (isset($this->body)) {
            $content = $this->body;
        }

        $content_type = 'application/x-www-form-urlencoded; charset=utf-8';
        if (substr($content, 0, 6) == '<?xml ') {
            $content_type = 'text/xml; charset=utf-8';
        }

        $this->request = array(
            'http' => array(
                'header' => 'Content-type: ' . $content_type,
                'method' => 'POST',
                'timeout' => 5,
                'max_redirects' => 0,
                'ignore_errors' => 1,
                'content' => $content,
            )
        );

        return $this;
    }
723917
protected function build()
    {
        $operation = $this->buildOperation('CreatePaymentToken');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);


        $pType = $this->document->createElement('pType', $this->pType);
        $operation->appendChild($pType);

        if ($this->templateSet) {
            $templateSet = $this->document->createElement('templateSet', $this->templateSet);
            $operation->appendChild($templateSet);
        }

        if ($this->style) {
            $style = $this->document->createElement('style', $this->style);
            $operation->appendChild($style);
        }

        if ($this->customerId) {
            $customerId = $this->document->createElement('customerID', $this->customerId);
            $operation->appendChild($customerId);
        }

        if ($this->profileId) {
            $profileId = $this->document->createElement('profileID', $this->profileId);
            $operation->appendChild($profileId);
        }

        if ($this->domain) {
            $domain = $this->document->createElement('domain', $this->domain);
            $operation->appendChild($domain);
        }


        if ($this->language) {
            $language = $this->document->createElement('language', $this->language);
            $operation->appendChild($language);
        }
    }
937422
public function build(): GetDocumentRequest
	{
		$instance = new GetDocumentRequest();
		$instance->depth = $this->depth;
		$instance->pierce = $this->pierce;
		return $instance;
	}
226638
public function CreateBody() {
    $body = '';

    if ($this->sign_key_file) {
      $body .= $this->GetMailMIME();
    }

    $this->SetWordWrap();

    switch($this->message_type) {
      case 'alt':
        $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
        $body .= $this->EncodeString($this->AltBody, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->EndBoundary($this->boundary[1]);
        break;
      case 'plain':
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        break;
      case 'attachments':
        $body .= $this->GetBoundary($this->boundary[1], '', '', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE;
        $body .= $this->AttachAll();
        break;
      case 'alt_attachments':
        $body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
        $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
        $body .= $this->EncodeString($this->AltBody, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->EndBoundary($this->boundary[2]);
        $body .= $this->AttachAll();
        break;
    }

    if ($this->IsError()) {
      $body = '';
    } elseif ($this->sign_key_file) {
      try {
        $file = tempnam('', 'mail');
        file_put_contents($file, $body); //TODO check this worked
        $signed = tempnam("", "signed");
        if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
          @unlink($file);
          @unlink($signed);
          $body = file_get_contents($signed);
        } else {
          @unlink($file);
          @unlink($signed);
          throw new phpmailerException($this->Lang("signing").openssl_error_string());
        }
      } catch (phpmailerException $e) {
        $body = '';
        if ($this->exceptions) {
          throw $e;
        }
      }
    }

    return $body;
  }
309030
protected function build()
    {
        $operation = $this->buildOperation('CreateCustomer');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        $pType = $this->document->createElement('pType', $this->pType);
        $operation->appendChild($pType);

        $paymentData = $this->document->createElement('paymentData');
        $paymentData->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:type', 'etp:PaymentData' . $this->pType);
        $paymentData = $operation->appendChild($paymentData);

        $this->appendArray($paymentData, $this->paymentData);

        $customerID = $this->document->createElement('customerID', $this->customerId);
        $operation->appendChild($customerID);
        $this->appendArray($operation, $this->additional);
    }
822625
public function build(): InsertTextRequest
	{
		$instance = new InsertTextRequest();
		if ($this->text === null) {
			throw new BuilderException('Property [text] is required.');
		}
		$instance->text = $this->text;
		return $instance;
	}
1017572
protected function build()
    {
        $operation = $this->buildOperation('SelectPayment');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        $xmlMdxi = $this->document->createElement('mdxi', $this->mdxi);
        $operation->appendChild($xmlMdxi);
    }
821264
protected function prepDocument()
    {
        /*
         * In some cases a body element can't be found (if the HTML is totally hosed for example)
         * so we create a new body node and append it to the document.
         */
        if (null === $this->body) {
            $this->body = $this->dom->createElement('body');
            $this->dom->documentElement->appendChild($this->body);
        }

        $this->body->setAttribute('class', 'readabilityBody');

        // Remove all style tags in head.
        $styleTags = $this->dom->getElementsByTagName('style');
        for ($i = $styleTags->length - 1; $i >= 0; --$i) {
            $styleTags->item($i)->parentNode->removeChild($styleTags->item($i));
        }

        $linkTags = $this->dom->getElementsByTagName('link');
        for ($i = $linkTags->length - 1; $i >= 0; --$i) {
            $linkTags->item($i)->parentNode->removeChild($linkTags->item($i));
        }
    }
239223
function create_body() {
      // wordwrap the message body if set
      if($this->WordWrap)
         $this->Body = $this->wordwrap($this->Body, $this->WordWrap);

      // If content type is multipart/alternative set body like this:
      if ((!empty($this->AltBody)) && (count($this->attachment) < 1))
      {
         // Return text of body
         $mime = array();
         $mime[] = "This is a MIME message. If you are reading this text, you\r\n";
         $mime[] = "might want to consider changing to a mail reader that\r\n";
         $mime[] = "understands how to properly display MIME multipart messages.\r\n\r\n";
         $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary);

         // Insert body. If multipart/alternative, insert both html and plain
         $mime[] = sprintf("Content-Type: %s; charset = \"%s\"; boundary = \"Boundary-=%s\";\r\n",
                           $this->ContentType, $this->CharSet, $this->subboundary);
         $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);

         $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary);
         $mime[] = sprintf("Content-Type: text/html; charset = \"%s\";\r\n", $this->CharSet);
         $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
         $mime[] = sprintf("%s\r\n\r\n", $this->Body);

         $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary);
         $mime[] = sprintf("Content-Type: text/plain; charset = \"%s\";\r\n", $this->CharSet);
         $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
         $mime[] = sprintf("%s\r\n\r\n", $this->AltBody);

         $mime[] = sprintf("\r\n--Boundary-=%s--\r\n\r\n", $this->subboundary);

         $mime[] = sprintf("\r\n--Boundary-=%s--\r\n", $this->boundary);

         $this->Body = $this->encode_string(join("", $mime), $this->Encoding);
      }
      else
      {
         $this->Body = $this->encode_string($this->Body, $this->Encoding);
      }


      if(count($this->attachment) > 0)
      {
         if(!$body = $this->attach_all())
            return false;
      }
      else
         $body = $this->Body;

      return($body);
   }
940930
public function buildRequest($method, $path, $body = null, $queryStrings = null, $conn = null, $queryMode = null, array $headers = array())
    {
        $request = new Request();
        $connection = $this->connectionManager->getConnection($conn);
        $request->setMethod(strtoupper($method));
        $request->setPath($path);
        $request->setBody($body);
        $request->setQueryStrings($queryStrings);
        $request->setConnection($connection->getAlias());
        $request->setQueryMode($queryMode);
        $request->setHeaders($headers);
        if ($connection->isAuth()) {
            $request->setAuthMode(true);
            $request->setUser($connection->getAuthUser());
            $request->setPassword($connection->getAuthPassword());
        }
        $url = $connection->getBaseUrl().$path;
        $request->setUrl($url);

        return $request;
    }
460762
public function onDocumentStart()
    {
        $this->documentElement = new PHPTAL_Dom_Element('documentElement', 'http://xml.zope.org/namespaces/tal', array(), $this->getXmlnsState());
        $this->documentElement->setSource($this->file, $this->line);
        $this->_current = $this->documentElement;
    }
821225
protected function buildForm()
    {
        if ($this->form) {
            return;
        }

        // append parent object if any
        // todo : clean the way the Admin class can retrieve set the object
        if ($this->isChild() && $this->getParentAssociationMapping()) {
            $parent = $this->getParent()->getObject($this->request->get($this->getParent()->getIdParameter()));

            $propertyAccessor = $this->getConfigurationPool()->getPropertyAccessor();
            $propertyPath = new PropertyPath($this->getParentAssociationMapping());

            $object = $this->getSubject();

            $value = $propertyAccessor->getValue($object, $propertyPath);

            if (\is_array($value) || ($value instanceof \Traversable && $value instanceof \ArrayAccess)) {
                $value[] = $parent;
                $propertyAccessor->setValue($object, $propertyPath, $value);
            } else {
                $propertyAccessor->setValue($object, $propertyPath, $parent);
            }
        }

        $formBuilder = $this->getFormBuilder();
        $formBuilder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
            $this->preValidate($event->getData());
        }, 100);

        $this->form = $formBuilder->getForm();
    }
1094692
function() {
        var options = this.options;

        return this.wrapper = this.render(options.wrapperTemplate)
            .addClass(Toolkit.buildTemplate(options.wrapperClass))
            .attr('id', this.id('wrapper'))
            .appendTo('body');
    }