public function MailhandlerAttachmentEnclosure::getFile in Mailhandler 6.2
Same name and namespace in other branches
- 7.2 plugins/mailhandler/commands/MailhandlerCommandsFiles.class.php \MailhandlerAttachmentEnclosure::getFile()
Save the attachment data the same way as the parent class for remote files.
Overrides FeedsEnclosure::getFile
File
- plugins/
mailhandler/ commands/ MailhandlerCommandsFiles.class.php, line 104 - MailhandlerCommandsFiles class.
Class
- MailhandlerAttachmentEnclosure
- Attachment enclosure, can be part of the result array.
Code
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;
}
}