You are here

public static function PlUploadFile::processPlUploadFile in Plupload integration 8

Same name and namespace in other branches
  1. 2.0.x src/Element/PlUploadFile.php \Drupal\plupload\Element\PlUploadFile::processPlUploadFile()

Render API callback: Expands the managed_file element type.

Expands the file type to include Upload and Remove buttons, as well as support for a default value.

Note: based on plupload_element_process().

File

src/Element/PlUploadFile.php, line 155

Class

PlUploadFile
Provides a PLUpload widget for uploading and saving files.

Namespace

Drupal\plupload\Element

Code

public static function processPlUploadFile(&$element, FormStateInterface $form_state, &$complete_form) {

  // Start session if not there yet. We need session if we want security
  // tokens to work properly.
  $session_manager = \Drupal::service('session_manager');
  if (!$session_manager
    ->isStarted()) {
    $session_manager
      ->start();
  }
  if (!isset($element['#upload_validators'])) {
    $element['#upload_validators'] = [];
  }
  $element['#upload_validators'] += _plupload_default_upload_validators();
  return $element;
}