You are here

class FormUploadedFile in Drupal 10

Provides a bridge to Symfony UploadedFile.

Hierarchy

Expanded class hierarchy of FormUploadedFile

1 file declares its use of FormUploadedFile
file.module in core/modules/file/file.module
Defines a "managed_file" Form API field and a "file" field for Field module.

File

core/modules/file/src/Upload/FormUploadedFile.php, line 10

Namespace

Drupal\file\Upload
View source
class FormUploadedFile implements UploadedFileInterface {

  /**
   * The wrapped uploaded file.
   *
   * @var \Symfony\Component\HttpFoundation\File\UploadedFile
   */
  protected $uploadedFile;

  /**
   * Creates a new FormUploadedFile.
   *
   * @param \Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile
   *   The wrapped Symfony uploaded file.
   */
  public function __construct(UploadedFile $uploadedFile) {
    $this->uploadedFile = $uploadedFile;
  }

  /**
   * {@inheritdoc}
   */
  public function getClientOriginalName() : string {
    return $this->uploadedFile
      ->getClientOriginalName();
  }

  /**
   * {@inheritdoc}
   */
  public function isValid() : bool {
    return $this->uploadedFile
      ->isValid();
  }

  /**
   * {@inheritdoc}
   */
  public function getErrorMessage() : string {
    return $this->uploadedFile
      ->getErrorMessage();
  }

  /**
   * {@inheritdoc}
   */
  public function getError() : int {
    return $this->uploadedFile
      ->getError();
  }

  /**
   * {@inheritdoc}
   */
  public function getSize() : int {
    return $this->uploadedFile
      ->getSize();
  }

  /**
   * {@inheritdoc}
   */
  public function getRealPath() {
    return $this->uploadedFile
      ->getRealPath();
  }

  /**
   * {@inheritdoc}
   */
  public function getPathname() : string {
    return $this->uploadedFile
      ->getPathname();
  }

  /**
   * {@inheritdoc}
   */
  public function getFilename() : string {
    return $this->uploadedFile
      ->getFilename();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormUploadedFile::$uploadedFile protected property The wrapped uploaded file.
FormUploadedFile::getClientOriginalName public function Returns the original file name. Overrides UploadedFileInterface::getClientOriginalName
FormUploadedFile::getError public function Returns the upload error code. Overrides UploadedFileInterface::getError
FormUploadedFile::getErrorMessage public function Returns an informative upload error message. Overrides UploadedFileInterface::getErrorMessage
FormUploadedFile::getFilename public function Gets the filename. Overrides UploadedFileInterface::getFilename
FormUploadedFile::getPathname public function Gets the path to the file. Overrides UploadedFileInterface::getPathname
FormUploadedFile::getRealPath public function Gets the absolute path to the file. Overrides UploadedFileInterface::getRealPath
FormUploadedFile::getSize public function Gets file size. Overrides UploadedFileInterface::getSize
FormUploadedFile::isValid public function Returns whether the file was uploaded successfully. Overrides UploadedFileInterface::isValid
FormUploadedFile::__construct public function Creates a new FormUploadedFile.