class FileUploadResult in Drupal 10
Value object for a file upload result.
Hierarchy
- class \Drupal\file\Upload\FileUploadResult
Expanded class hierarchy of FileUploadResult
File
- core/
modules/ file/ src/ Upload/ FileUploadResult.php, line 10
Namespace
Drupal\file\UploadView source
class FileUploadResult {
/**
* If the filename was renamed for security reasons.
*
* @var bool
*/
protected $securityRename = FALSE;
/**
* The sanitized filename.
*
* @var string
*/
protected $sanitizedFilename;
/**
* The original filename.
*
* @var string
*/
protected $originalFilename;
/**
* The File entity.
*
* @var \Drupal\file\FileInterface
*/
protected $file;
/**
* Flags the result as having had a security rename.
*
* @return $this
*/
public function setSecurityRename() : FileUploadResult {
$this->securityRename = TRUE;
return $this;
}
/**
* Sets the sanitized filename.
*
* @param string $sanitizedFilename
* The sanitized filename.
*
* @return $this
*/
public function setSanitizedFilename(string $sanitizedFilename) : FileUploadResult {
$this->sanitizedFilename = $sanitizedFilename;
return $this;
}
/**
* Gets the original filename.
*
* @return string
*/
public function getOriginalFilename() : string {
return $this->originalFilename;
}
/**
* Sets the original filename.
*
* @param string $originalFilename
* The original filename.
*
* @return $this
*/
public function setOriginalFilename(string $originalFilename) : FileUploadResult {
$this->originalFilename = $originalFilename;
return $this;
}
/**
* Sets the File entity.
*
* @param \Drupal\file\FileInterface $file
* A file entity.
*
* @return $this
*/
public function setFile(FileInterface $file) : FileUploadResult {
$this->file = $file;
return $this;
}
/**
* Returns if there was a security rename.
*
* @return bool
*/
public function isSecurityRename() : bool {
return $this->securityRename;
}
/**
* Returns if there was a file rename.
*
* @return bool
*/
public function isRenamed() : bool {
return $this->originalFilename !== $this->sanitizedFilename;
}
/**
* Gets the sanitized filename.
*
* @return string
*/
public function getSanitizedFilename() : string {
return $this->sanitizedFilename;
}
/**
* Gets the File entity.
*
* @return \Drupal\file\FileInterface
*/
public function getFile() : FileInterface {
return $this->file;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileUploadResult:: |
protected | property | The File entity. | |
FileUploadResult:: |
protected | property | The original filename. | |
FileUploadResult:: |
protected | property | The sanitized filename. | |
FileUploadResult:: |
protected | property | If the filename was renamed for security reasons. | |
FileUploadResult:: |
public | function | Gets the File entity. | |
FileUploadResult:: |
public | function | Gets the original filename. | |
FileUploadResult:: |
public | function | Gets the sanitized filename. | |
FileUploadResult:: |
public | function | Returns if there was a file rename. | |
FileUploadResult:: |
public | function | Returns if there was a security rename. | |
FileUploadResult:: |
public | function | Sets the File entity. | |
FileUploadResult:: |
public | function | Sets the original filename. | |
FileUploadResult:: |
public | function | Sets the sanitized filename. | |
FileUploadResult:: |
public | function | Flags the result as having had a security rename. |