/** * Deals with multipart requests. * @return ['content' => $content, 'attachments' => $attachments]. */ private function getParts() { $content = \LockerRequest::getContent(); $contentType = \LockerRequest::header('Content-Type'); $types = explode(';', $contentType, 2); $mimeType = count($types) >= 1 ? $types[0] : $types; if ($mimeType == 'multipart/mixed') { $components = Attachments::setAttachments($contentType, $content); // Returns 'formatting' error. if (empty($components)) { throw new Exceptions\Exception('There is a problem with the formatting of your submitted content.'); } // Returns 'no attachment' error. if (!isset($components['attachments'])) { throw new Exceptions\Exception('There were no attachments.'); } $content = $components['body']; $attachments = $components['attachments']; } else { $attachments = []; } return ['content' => $content, 'attachments' => $attachments]; }