@param FieldListMessage $message

@return Field[]
496865
public function getFields(FieldListMessage $message): array
    {
        $path = sprintf('sites/%d/fields', $message->getSiteId());

        $response = $this->getClient()->sendRequest('GET', $path);

        /** @var Field[] $models */
        $models = $this->getModelFactory()->createMany(Field::class, $response);

        return $models;
    }
1284991
protected function getFromAddresses(Swift_Mime_SimpleMessage $message)
    {
        if ($message->getFrom()) {
            foreach ($message->getFrom() as $address => $name) {
                return [$address, $name];
            }
        }
        return [];
    }
1186509
public function messages($field)
    {
        return (isset($this->data[$field]) && $messages = $this->data[$field]['messages']) ? $messages : array();
    }
776165
private function messageLoggerContext(MessageInterface $message): array
    {
        return [
            'id' => $message->getId(),
            'created' => $message->getCreated(),
            'type' => $message->getType(),
            'payload' => $message->getPayload(),
        ];
    }
159120
public function uploadMedias(MediaUploadMessage $message): array
    {
        $message->initBuilder();

        $path    = sprintf('sites/%d/uploads/media', $message->getSiteId());
        $body    = $message->build();
        $headers = $message->buildHeaders();

        $response = $this->getClient()->sendRequest('POST', $path, $body, $headers);

        /** @var Media[] $model */
        $model = $this->getModelFactory()->createMany(Media::class, $response);

        return $model;
    }
942947
public function prepareMessage($message)
    {
        list($text, $level, $category, $timestamp) = $message;

        $result = [
            'category' => $category,
            'level' => Logger::getLevelName($level),
            '@timestamp' => date('c', $timestamp),
        ];

        if (isset($message[4])) {
            $result['trace'] = $message[4];
        }

        //Exceptions get parsed into an array, text and arrays are passed as is, other types are var_dumped
        if ($text instanceof \Exception) {
            //convert exception to array for easier analysis
            $result['message'] = [
                'message' => $text->getMessage(),
                'file' => $text->getFile(),
                'line' => $text->getLine(),
                'trace' => $text->getTraceAsString(),
            ];
        } elseif (is_array($text) || is_string($text)) {
            $result['message'] = $text;
        } else {
            $result['message'] = VarDumper::export($text);
        }

        if ($this->includeContext) {
            $result['context'] = $this->getContextMessage();
        }

        $message = implode("\n", [
            Json::encode([
                'index' => new \stdClass()
            ]),
            Json::encode($result)
        ]);

        return $message;
    }
967034
protected function getSchemaForMessage($message)
    {
        // Form schema messages treat simple strings as plain text, so nest for html messages
        $value = $message['message'];
        if ($message['messageCast'] === ValidationResult::CAST_HTML) {
            $value = ['html' => $message];
        }
        return [
            'value' => $value,
            'type' => $message['messageType'],
            'field' => empty($message['fieldName']) ? null : $message['fieldName'],
        ];
    }
1256537
private function buildAttachments(Swift_Mime_Message $message)
    {
        $attachments = [];

        foreach ($message->getChildren() as $part) {
            if ($part instanceof Swift_Attachment) {
                $attachments[] = [
                    'type' => $part->getContentType(),
                    'name' => $part->getFilename(),
                    'data' => base64_encode($part->getBody()),
                ];
            }
        }

        return $attachments;
    }
1061837
private function getFrom(Swift_Mime_SimpleMessage $message)
    {
        if ($message->getFrom()) {
            foreach ($message->getFrom() as $email => $name) {
                return ['email' => $email, 'name' => $name];
            }
        }
        return [];
    }
68201
protected function flattenSubMessages(
        string $fieldName,
        array $subMessages,
        array $messages
    ): array {
        foreach ($subMessages as $subFieldName => $subFieldMessages) {
            $fieldNamePath = $this->buildFieldName($fieldName, $subFieldName);

            $messages[$fieldNamePath] = $subFieldMessages;
        }

        return $messages;
    }
1311969
protected function getPostedAction($message = true)
    {
        $action = $this->getPosted('action', array(), true, 'array');

        if (!empty($action)) {

            if (empty($action['name'])) {
                $error = $this->text('An error occurred');
            } else if (empty($action['items'])) {
                $error = $this->text('Please select at least one item');
            } else {
                $parts = explode('|', $action['name'], 2);
                return array($action['items'], $parts[0], isset($parts[1]) ? $parts[1] : null);
            }

            if (isset($error) && $message) {
                $this->setMessage($error, 'warning');
            }
        }

        return array(array(), null, null);
    }
1038897
public function gettext($message) {
		$args = func_get_args();
		$methodArgsNumber = 1;
		$message = $this->callMethodAndSprintf(__FUNCTION__, $args, $methodArgsNumber);
		return $message;
	}
489180
protected function getFromAddresses(Swift_Mime_Message $message)
	{
		if ($message->getFrom()) {
			foreach ($message->getFrom() as $address => $name) {
				return [$address, $name];
			}
		}
		return [];
	}
1020276
private function getUserMessages(Message $message)
    {
        $currentUser = $this->tokenStorage->getToken()->getUser();

        return $this->om->getRepository(UserMessage::class)->findBy(['message' => $message, 'user' => $currentUser]);
    }
977803
public function route(Message $message) : array
    {
        if (!is_object($message->getPayload())) {
            throw new InvalidArgumentException("Can't route by payload type, when payload is not object. Got: {$message->getPayload()}");
        }

        $classToRoute = get_class($message->getPayload());
        if ($this->routeByClassName) {
            return [$classToRoute];
        }

        $channelsToRoute = [];
        foreach ($this->typeToChannelMapping as $type => $channelName) {
            if ($classToRoute === $type) {
                $channelsToRoute[] = $channelName;
            }
        }

        return $channelsToRoute;
    }
461155
public function getFiles(array $message)
    {
        return Collection::make($message['message']['attachments'])->where('type',
            'file')->pluck('payload')->map(function ($item) {
                return new File($item['url'], $item);
            })->toArray();
    }
13805
protected function getToAddresses( Swift_Mime_Message $message )
	{
		$to = [];

		if ( $message->getTo() )
			$to = array_merge( $to, array_keys( $message->getTo() ) );

		if ( $message->getCc() )
			$to = array_merge( $to, array_keys( $message->getCc() ) );

		if ( $message->getBcc() )
			$to = array_merge( $to, array_keys( $message->getBcc() ) );

		return $to;
	}