class MailhandlerAttachmentEnclosure in Mailhandler 6.2
Same name and namespace in other branches
- 7.2 plugins/mailhandler/commands/MailhandlerCommandsFiles.class.php \MailhandlerAttachmentEnclosure
Attachment enclosure, can be part of the result array.
Hierarchy
- class \FeedsElement
- class \FeedsEnclosure
Expanded class hierarchy of MailhandlerAttachmentEnclosure
File
- plugins/
mailhandler/ commands/ MailhandlerCommandsFiles.class.php, line 45 - MailhandlerCommandsFiles class.
View source
class MailhandlerAttachmentEnclosure extends FeedsEnclosure {
/**
* The Content-ID.
*
* @var string
*/
protected $cid;
/**
* The file content.
*
* @var string
*/
protected $data;
/**
* Constructs an attachment enclosure.
*
* @param string $filename
* The file name.
* @param string $mime_type
* The mime type.
* @param string $data
* The file content.
* @param string $cid
* (optional) The Content-ID.
*/
public function __construct($filename, $mime_type, $data, $cid = NULL) {
parent::__construct($filename, $mime_type);
$this->data = $data;
$this->cid = $cid;
}
/**
* Get the Content-ID.
*
* @return string
* The Content-ID or NULL if it is not defined.
*/
public function getContentId() {
return $this->cid;
}
/**
* Get the file content.
*
* @return string
* The file content.
*/
public function getContent() {
return $this->data;
}
/**
* {@inheritdoc}
*
* Save the attachment data the same way as the parent class for remote files.
*/
public function getFile($destination, $replace = FILE_EXISTS_RENAME) {
$file = FALSE;
if ($this
->getValue()) {
// Prepare destination directory.
file_prepare_directory($destination, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY);
try {
$filename = $this
->getLocalValue();
if (module_exists('transliteration')) {
require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
$filename = transliteration_clean_filename($filename);
}
$file = file_save_data($this
->getContent(), $destination . $filename, $replace);
} catch (Exception $e) {
watchdog_exception('Feeds', $e, nl2br(check_plain($e)));
}
// We couldn't make sense of this enclosure, throw an exception.
if (!$file) {
throw new Exception(t('Invalid enclosure %enclosure', array(
'%enclosure' => $this
->getValue(),
)));
}
return $file;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsElement:: |
protected | property | ||
FeedsElement:: |
public | function | @todo Make value public and deprecate use of getValue(). | 3 |
FeedsElement:: |
public | function | 1 | |
FeedsEnclosure:: |
protected | property | Delete flag, denoting whether a file should be deleted when this object is destroyed. | |
FeedsEnclosure:: |
protected | property | ||
FeedsEnclosure:: |
protected | property | ||
FeedsEnclosure:: |
public | function | 1 | |
FeedsEnclosure:: |
public | function | Destructor, clean up any temporary files. | |
MailhandlerAttachmentEnclosure:: |
protected | property | The Content-ID. | |
MailhandlerAttachmentEnclosure:: |
protected | property | The file content. | |
MailhandlerAttachmentEnclosure:: |
public | function |
Get the file content. Overrides FeedsEnclosure:: |
|
MailhandlerAttachmentEnclosure:: |
public | function | Get the Content-ID. | |
MailhandlerAttachmentEnclosure:: |
public | function |
Save the attachment data the same way as the parent class for remote files. Overrides FeedsEnclosure:: |
|
MailhandlerAttachmentEnclosure:: |
public | function |
Constructs an attachment enclosure. Overrides FeedsEnclosure:: |