You are here

public function Upload::getForm in Media entity video 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/EntityBrowser/Widget/Upload.php \Drupal\media_entity_video\Plugin\EntityBrowser\Widget\Upload::getForm()
  2. 8.2 src/Plugin/EntityBrowser/Widget/Upload.php \Drupal\media_entity_video\Plugin\EntityBrowser\Widget\Upload::getForm()

File

src/Plugin/EntityBrowser/Widget/Upload.php, line 34

Class

Upload
Uses upload to create media entity videos.

Namespace

Drupal\media_entity_video\Plugin\EntityBrowser\Widget

Code

public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) {

  /** @var \Drupal\media_entity\MediaBundleInterface $bundle */
  if (!$this->configuration['media bundle'] || !($bundle = $this->entityTypeManager
    ->getStorage('media_bundle')
    ->load($this->configuration['media bundle']))) {
    return [
      '#markup' => $this
        ->t('The media bundle is not configured correctly.'),
    ];
  }
  if ($bundle
    ->getType()
    ->getPluginId() != 'video') {
    return [
      '#markup' => $this
        ->t('The configured bundle is not using video plugin.'),
    ];
  }
  $form = parent::getForm($original_form, $form_state, $aditional_widget_parameters);
  $form['upload']['#upload_validators']['file_validate_extensions'] = [
    $this->configuration['extensions'],
  ];
  return $form;
}