Transform payload

@param Template $message

@return array
434590
public function transform(Template $message)
    {
        return array_merge([
            'template_type' => 'list',
            'top_element_style' => $message->getTopStyle(),
            'elements' => $message->getCollections()->toData(),
        ], $message->getButton() !== null ? ['buttons' => [$message->getButton()->toData()]] : []);
    }
1070663
protected function transform($messages, $format)
        {
            $messages = (array) $messages;

            foreach ($messages as $key => &$message) {
                $message = repl(':message', $message, $format);
            }

            return $messages;
        }
1002260
private function getAttachmentsAsArrays(Message $message): array
    {
        $attachments = [];

        foreach ($message->getAttachments() as $attachment) {
            $attachments[] = $attachment->toArray();
        }

        return $attachments;
    }
746294
protected function filterHtml( $message )
	{
		$message = strip_shortcodes( $message );
		$message = wptexturize( $message );
		$message = wpautop( $message );
		$message = str_replace( ['&lt;&gt; ', ']]>'], ['', ']]&gt;'], $message );
		$message = stripslashes( $message );
		return $message;
	}
1067239
public function transform(Message $message) : Message
    {
        $evaluatedPayload = $this->expressionEvaluationService->evaluate($this->expression,
            [
                "payload" => $message->getPayload(),
                "headers" => $message->getHeaders()->headers()
            ],
            $this->referenceSearchService
        );

        return MessageBuilder::fromMessage($message)
                    ->setPayload($evaluatedPayload)
                    ->build();
    }
855682
public function translate($message)
    {
        $locale = $this->configuration
            ->get('i18n.locale', $this->fallbackLocale);

        return $this->getTranslatorService()
            ->translate($message, $this->domain, $locale);
    }
105358
private function parseMessage($message)
    {
        $string = $message;

        if (is_array($message)) {
            $format = '"%s" %s';
            $errors = array();

            foreach ($message as $field => $messages) {
                if (is_array($messages)) {
                    $messages = array_unique($messages);
                    foreach ($messages as $error) {
                        $errors[] = sprintf($format, $field, $error);
                    }
                } elseif (is_integer($field)) {
                    $errors[] = $messages;
                } else {
                    $errors[] = sprintf($format, $field, $messages);
                }
            }

            $string = implode(', ', $errors);
        }

        return $string;
    }
348417
public static function encodeMessage($message)
    {
        $waitingData = strlen($message);
        $header = str_pad((string)$waitingData,8,'0',STR_PAD_LEFT);
        return $header.$message;
    }
728529
protected function interpolate($message, $context = array())
    {
        $replace = array();
        foreach ($context as $key => $value) {
            $replace['{' . $key . '}'] = $value;
        }
        return strtr($message, $replace);
    }
28598
public function prepareTranslatedMessage(array $message = [])
    {
        $translatedMessage = \App\Registry::$translate->_($message['message']);
        array_unshift($message['vars'], $translatedMessage);
        return call_user_func_array('sprintf', $message['vars']);
    }
703183
private function _prepareMessage($message)
    {
        if (is_string($message) || is_numeric($message)) {
            return $message;
        }
        
        if (is_array($message)) {
            return json_encode($message, JSON_UNESCAPED_UNICODE);
        }
        
        return null;
    }
337458
public function dispatch($message): Envelope
    {
        $messageName = $this->getMessageName($message);

        if ($this->isIncoming($message)) {
            $this->decrementMessageQueueSize($messageName);
        } else {
            $this->incrementMessageQueueSize($messageName);
        }

        return $this->innerBus->dispatch($message);
    }
60915
public function save(Message $message) : ?Message
    {
        $aggregate = $message->getHeaders()->get(AggregateMessage::AGGREGATE_OBJECT);

        $this->aggregateRepository->save($message->getHeaders()->get(AggregateMessage::CALLING_MESSAGE), $aggregate);

        if ($message->getHeaders()->get(AggregateMessage::IS_FACTORY_METHOD)) {
            $aggregate = $message->getHeaders()->get(AggregateMessage::AGGREGATE_OBJECT);
            $aggregateIds = [];

            foreach ($message->getHeaders()->get(AggregateMessage::AGGREGATE_ID) as $aggregateIdName => $aggregateIdValue) {
                $aggregateIds[$aggregateIdName] = $this->propertyReaderAccessor->getPropertyValue(PropertyPath::createWith($aggregateIdName), $aggregate);
            }

            $payload = count($aggregateIds) === 1 ? array_shift($aggregateIds) : $aggregateIds;

            return
                MessageBuilder::fromMessage($message)
                    ->setPayload($payload)
                    ->build();
        }

        return $message;
    }
1232812
private function formatMessage($message)
    {
        $formattedMessage = implode('', (array)$message);
        $formattedMessage = str_replace(PHP_EOL, '', $formattedMessage);
        $formattedMessage = strip_tags($formattedMessage);
        $formattedMessage = preg_replace([
            '/\\x1b[[][^A-Za-z]*[A-Za-z]/',
            '/[-=]{2,}/',
        ], '', $formattedMessage);

        return $formattedMessage !== null
            ? trim($formattedMessage, " \t\n\r\0\x0B-=")
            : (string)$formattedMessage;
    }
1352400
public function queue(array $message, $template = false, array $templateVars = [])
    {
        $message = $this->compressMessage($message);
        $variables = $this->compressMessage($templateVars);

        $body = [
            'm' => $message,
            't' => $template,
            'v' => $variables,
        ];
        $body = json_encode($body);

        return $this->getQueue()->enqueue($body);
    }
23314
private function createFromTemplate($message, $template) {
        ob_start();
        ob_implicit_flush(false);

        if (is_array($message) && !empty($message)) {
            extract($message, EXTR_OVERWRITE);
        }

        $current_module = RouteController::$currentRoute['module'];
        $templatePath = MODULES_DIR . '/' . $current_module . '/Views/' . $template . '.php';
        require $templatePath;
        return ob_get_clean();
    }
1218822
public function parseResponse($message)
    {
        if (!($parts = $this->parseMessage($message))) {
            return false;
        }

        list($protocol, $version) = explode('/', trim($parts['start_line'][0]));

        return [
            'protocol'         => $protocol,
            'protocol_version' => $version,
            'code'             => $parts['start_line'][1],
            'reason_phrase'    => isset($parts['start_line'][2]) ? $parts['start_line'][2] : '',
            'headers'          => $parts['headers'],
            'body'             => $parts['body']
        ];
    }