Builds message structure.

@return array Built message structure.
339739
public function buildMessage()
    {
        $messages = [];
        foreach ($this->messageBuilders as $messageBuilder) {
            foreach ($messageBuilder->buildMessage() as $message) {
                $messages[] = $message;
            }
        }

        return $messages;
    }
1059189
public function buildMessage()
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        foreach ($this->texts as $text) {
            $this->message[] = [
                'type' => MessageType::TEXT,
                'text' => $text,
            ];
        }

        if ($this->quickReply) {
            $lastKey = count($this->message) - 1;

            // If the user receives multiple message objects.
            // The quickReply property of the last message object is displayed.
            $this->message[$lastKey]['quickReply'] = $this->quickReply->buildQuickReply();
        }

        return $this->message;
    }
1011657
protected static function buildStructures()
    {
		$perspectives = array();
		$toAdd = array();
		$sorted = \helpers_ExtensionHelper::sortByDependencies(\common_ext_ExtensionsManager::singleton()->getEnabledExtensions());
		foreach(array_keys($sorted) as $extId){
			$file = self::getStructuresFilePath($extId);
			if(!is_null($file)){
			    $xmlStructures = new \SimpleXMLElement($file, null, true);
				$extStructures = $xmlStructures->xpath("/structures/structure");
				foreach($extStructures as $xmlStructure){
				    $perspective = Perspective::fromSimpleXMLElement($xmlStructure, $extId);
				    if (!isset($perspectives[$perspective->getId()])) {
				        $perspectives[$perspective->getId()] = $perspective;
				    } else {
				        foreach ($perspective->getChildren() as $section) {
				            $perspectives[$perspective->getId()]->addSection($section);
				        }
				    }
				}
				foreach($xmlStructures->xpath("/structures/toolbar/toolbaraction") as $xmlStructure){
				    $perspective = Perspective::fromLegacyToolbarAction($xmlStructure, $extId);
			        $perspectives[$perspective->getId()] = $perspective;
			        if (isset($xmlStructure['structure'])) {
			            $toAdd[$perspective->getId()] = (string)$xmlStructure['structure'];  
			        }
				}
			}
		}
		
		foreach ($toAdd as $to => $from) {
		    if (isset($perspectives[$from]) && isset($perspectives[$to])) {
		        foreach($perspectives[$from]->getChildren() as $section) {
		            $perspectives[$to]->addSection($section);
		        }
		    } 
		}

        usort($perspectives, function ($a, $b) {
            return $a->getLevel() - $b->getLevel();
        });

		return array(
			'perspectives' => $perspectives
		);
    }
83811
private function getMessages()
    {
        $messages = [];
        $content = '';
        fseek($this->fh, 0);
        while (!feof($this->fh)) {
            $content .= fgets($this->fh);
        }
        if ($content) {
            $messages = json_decode($content, true);
        }
        return $messages;
    }
863585
protected function build()
    {
        $events = [];

        foreach ($this->queue as $report) {
            $event = $report->toArray();

            if ($event) {
                $events[] = $event;
            }
        }

        return [
            'apiKey' => $this->config->getApiKey(),
            'notifier' => $this->config->getNotifier(),
            'events' => $events,
        ];
    }
413136
public function buildHeader() {
    $header['id'] = $this->t('Internal ID');
    $header['name'] = $this->t('Name');
    $header['mail'] = $this->t('Email');
    $header['region'] = $this->t('Branch (Region)');
    $header['membership_id'] = $this->t('Membership ID');
    $header['is_employee'] = $this->t('Employee');
    $header['checkins'] = $this->t('Checkins');
    $header['campaigns'] = $this->t('Campaigns');
    return $header + parent::buildHeader();
  }
342121
public function buildMessage()
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        $imageMessage = [
            'type' => MessageType::IMAGE,
            'originalContentUrl' => $this->originalContentUrl,
            'previewImageUrl' => $this->previewImageUrl,
        ];

        if ($this->quickReply) {
            $imageMessage['quickReply'] = $this->quickReply->buildQuickReply();
        }

        $this->message[] = $imageMessage;

        return $this->message;
    }
332034
protected function buildMessageHeader()
    {
        $len = 0;
        foreach ($this->segments as $segment) {
            $len += strlen($segment);
        }

        return new HNHBK($len, $this->dialogId, $this->messageNumber);
    }
541103
protected function loadMessages()
    {
        $messages = Collection::make($this->event->get('messaging'));
        $messages = $messages->transform(function ($msg) {
            $message = new IncomingMessage('', $this->getMessageSender($msg), $this->getMessageRecipient($msg), $msg);
            if (isset($msg['message']['text']) && ! isset($msg['message']['quick_reply']['payload'])) {
                $message->setText($msg['message']['text']);

                if (isset($msg['message']['nlp'])) {
                    $message->addExtras('nlp', $msg['message']['nlp']);
                }
            } elseif (isset($msg['postback']['payload'])) {
                $this->isPostback = true;

                $message->setText($msg['postback']['payload']);
            } elseif (isset($msg['message']['quick_reply']['payload'])) {
                $this->isPostback = true;

                $message->setText($msg['message']['quick_reply']['payload']);
            }

            return $message;
        })->toArray();

        if (count($messages) === 0) {
            $messages = [new IncomingMessage('', '', '')];
        }

        $this->messages = $messages;
    }
766256
public function build()
    {
        $params = [
            'external_user_ids' => $this->externalUserIds,
            'segment_id' => $this->segmentId,
            'campaign_id' => $this->campaignId,
            'override_frequency_capping' => $this->overrideFrequencyCapping,
            'recipient_subscription_state' => $this->recipientSubscriptionState,
            'messages' => $this->messages,
        ];

        return array_filter($params, function ($param) {
            return $param !== null;
        });
    }
841203
protected function get_messages()
    {
        $lang_file = __DIR__.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$this->lang.'.php';
        $messages = require $lang_file;

        if ($validation_methods_errors = self::$validation_methods_errors) {
            $messages = array_merge($messages, $validation_methods_errors);
        }
        return $messages;
    }
640268
protected function buildMessage()
    {
        if (empty($this->plainMessage) && empty($this->htmlMessage)) {
            return '';
        }
        if (!empty($this->plainMessage) && empty($this->htmlMessage)) {
            return $this->plainMessage;
        }
        if (empty($this->plainMessage) && !empty($this->htmlMessage)) {
            return $this->htmlMessage;
        }

        $message = array();
        array_push($message, "--{$this->boundaryAlternative}");
        $message = array_merge($message, $this->buildPlainMessageHeader());
        array_push($message, $this->plainMessage);
        array_push($message, "--{$this->boundaryAlternative}");
        $message = array_merge($message, $this->buildHtmlMessageHeader());
        array_push($message, $this->htmlMessage);
        array_push($message, "--{$this->boundaryAlternative}--");

        return implode(self::LINE_BREAK, $message);
    }
651556
protected function buildMessageWithAttachments()
    {
        $message = array();

        if (!empty($this->plainMessage) || !empty($this->htmlMessage)) {
            array_push($message, "--{$this->boundaryMixed}");
        }

        if (!empty($this->plainMessage) && !empty($this->htmlMessage)) {
            array_push($message, "Content-Type: multipart/alternative; boundary={$this->boundaryAlternative}");
            array_push($message, '');
            array_push($message, "--{$this->boundaryAlternative}");
            $message = array_merge($message, $this->buildPlainMessageHeader());
            array_push($message, $this->plainMessage);
            array_push($message, "--{$this->boundaryAlternative}");
            $message = array_merge($message, $this->buildHtmlMessageHeader());
            array_push($message, $this->htmlMessage);
            array_push($message, "--{$this->boundaryAlternative}--");
            array_push($message, '');
        } elseif (!empty($this->plainMessage)) {
            $message = array_merge($message, $this->buildPlainMessageHeader());
            array_push($message, $this->plainMessage);
        } elseif (!empty($this->htmlMessage)) {
            $message = array_merge($message, $this->buildHtmlMessageHeader());
            array_push($message, $this->htmlMessage);
        }
        foreach ($this->attachments as $attachment) {
            array_push($message, "--{$this->boundaryMixed}");
            array_push($message, "Content-Type: {$attachment['type']}; name=\"{$attachment['title']}\"");
            array_push($message, 'Content-Transfer-Encoding: base64');
            array_push($message, 'Content-Disposition: attachment');
            array_push($message, '');
            array_push($message, $this->buildAttachmentContent($attachment['path']));
        }
        array_push($message, "--{$this->boundaryMixed}--");

        return implode(self::LINE_BREAK, $message);
    }
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;
    }
1141853
public function build()
    {
        return $this->from($this->email, $this->title)
            ->subject('Subject: '.$this->messages['subject'])
            ->view('extras::messages.email');
    }
1052268
public function getDetailMessages()
    {
        $messages = array();
        foreach ($this->invalidRules as $field => $rules) {
            foreach ($rules as $rule) {
                $messages[$field][$rule] = $this->ruleValidators[$field][$rule]->getMessages();
            }
        }
        return $messages;
    }
1317780
public function build()
    {
        return $this->subject($this->subject)
            ->replyTo($this->notification_owner->email, $this->notification_owner->name)
            ->view($this->template)
            ->with($this->data);
    }