You are here

protected function WebformManagedFileBase::getFile in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformManagedFileBase.php \Drupal\webform\Plugin\WebformElement\WebformManagedFileBase::getFile()

Get file.

Parameters

array $element: An element.

array|mixed $value: A value.

array $options: An array of options.

Return value

\Drupal\file\FileInterface A file.

4 calls to WebformManagedFileBase::getFile()
WebformImageFile::formatHtmlItem in src/Plugin/WebformElement/WebformImageFile.php
Format an element's value as HTML.
WebformManagedFileBase::formatHtmlItem in src/Plugin/WebformElement/WebformManagedFileBase.php
Format an element's value as HTML.
WebformManagedFileBase::formatTextItem in src/Plugin/WebformElement/WebformManagedFileBase.php
Format an element's value as text.
WebformManagedFileBase::getTargetEntity in src/Plugin/WebformElement/WebformManagedFileBase.php
Get referenced entity.

File

src/Plugin/WebformElement/WebformManagedFileBase.php, line 444

Class

WebformManagedFileBase
Provides a base class webform 'managed_file' elements.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function getFile(array $element, $value, array $options) {

  // The value is an array when the posted back file has not been processed
  // and it should ignored.
  if (empty($value) || is_array($value)) {
    return NULL;
  }
  if ($value instanceof FileInterface) {
    return $value;
  }
  return $this->entityTypeManager
    ->getStorage('file')
    ->loadUnchanged($value);
}