19 $this->disposition =
'attachment';
20 $this->setId(uniqid(
'attachment'));
46 elgg_log(__METHOD__ .
': $options needs to be an array', \Psr\Log\LogLevel::ERROR);
51 elgg_log(__METHOD__ .
': $options "content" or "filepath" is required', \Psr\Log\LogLevel::ERROR);
59 if (empty($filepath) || !is_file($filepath)) {
60 elgg_log(__METHOD__ .
': $options[filepath] didn\'t result in a valid file', \Psr\Log\LogLevel::ERROR);
64 $content = file_get_contents($filepath);
69 $options[
'filename'] = basename($filepath);
82 $attachment->$key =
$value;
__construct($content= '')
exists()
Returns if the file exists.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
grabFile()
Gets the full contents of this file.
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
getFilename()
Return the filename.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
getMimeType()
Get the mime type of the file.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
$content
Set robots.txt action.
_elgg_services()
Get the global service provider.
static factory($options)
Create an attachment.
static fromElggFile(\ElggFile $file)
Create an attachment from an ElggFile.