You are here

class FileUploadResponse in GraphQL 8.4

A response that either has a file entity or some violations.

Hierarchy

Expanded class hierarchy of FileUploadResponse

1 file declares its use of FileUploadResponse
FileUpload.php in src/GraphQL/Utility/FileUpload.php

File

src/GraphQL/Response/FileUploadResponse.php, line 12

Namespace

Drupal\graphql\GraphQL\Response
View source
class FileUploadResponse extends Response {

  /**
   * The file entities in case of successful file upload.
   *
   * @var \Drupal\file\FileInterface[]
   */
  protected $fileEntities = [];

  /**
   * Sets file entity.
   *
   * @param \Drupal\file\FileInterface $fileEntity
   *   File entity.
   */
  public function setFileEntity(FileInterface $fileEntity) : void {
    $this->fileEntities[] = $fileEntity;
  }

  /**
   * Sets file entities.
   *
   * @param \Drupal\file\FileInterface[] $fileEntities
   *   File entities.
   */
  public function setFileEntities(array $fileEntities) : void {
    $this->fileEntities = $fileEntities;
  }

  /**
   * Get the first file entity if there is one.
   *
   * @return \Drupal\file\FileInterface|null
   *   First file entity or NULL.
   */
  public function getFileEntity() : ?FileInterface {
    return $this->fileEntities[0] ?? NULL;
  }

  /**
   * Get the file entities.
   *
   * @return \Drupal\file\FileInterface[]
   *   File entities.
   */
  public function getFileEntities() : array {
    return $this->fileEntities;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileUploadResponse::$fileEntities protected property The file entities in case of successful file upload.
FileUploadResponse::getFileEntities public function Get the file entities.
FileUploadResponse::getFileEntity public function Get the first file entity if there is one.
FileUploadResponse::setFileEntities public function Sets file entities.
FileUploadResponse::setFileEntity public function Sets file entity.
Response::$violations protected property List of violations.
Response::addViolation public function Adds the violation. Overrides ResponseInterface::addViolation
Response::addViolations public function Adds multiple violations. Overrides ResponseInterface::addViolations
Response::getViolations public function Gets the violations. Overrides ResponseInterface::getViolations
Response::mergeViolations public function Adds the violations from another response to this response. Overrides ResponseInterface::mergeViolations