/** * @param Attachment[] $attachments * @return array An array containing arrays of the following format: * array( * 'Name' => name, * 'Content' => base64-encoded content, * 'ContentType' => type, * (optional) 'ContentID' => id, * ) */ protected function processAttachments(array $attachments) { $attachments = AttachmentUtils::processAttachments($attachments); $processedAttachments = array(); foreach ($attachments as $name => $attachment) { $item = array('Name' => $name, 'Content' => base64_encode($this->getAttachmentContent($attachment)), 'ContentType' => $attachment->getType()); $id = $attachment->getId(); if (isset($id)) { $item['ContentID'] = $id; } $processedAttachments[] = $item; } return $processedAttachments; }
/** * @param Attachment[] $attachments * @return array First element: All attachments – array(name => path). Second element: Inline attachments – array(id => name) */ protected function processAttachments(array $attachments) { $attachments = AttachmentUtils::processAttachments($attachments); $processedAttachments = array(); $inline = array(); foreach ($attachments as $name => $attachment) { $id = $attachment->getId(); if (isset($id)) { // Reference inline $inline[$id] = $name; } $processedAttachments[$name] = $attachment->getPath(); } return array($processedAttachments, $inline); }