You are here

protected function MediaEditForm::getTargetBundles in Media Directories 2.x

Same name and namespace in other branches
  1. 8 modules/media_directories_ui/src/Form/MediaEditForm.php \Drupal\media_directories_ui\Form\MediaEditForm::getTargetBundles()
  2. 3.x modules/media_directories_ui/src/Form/MediaEditForm.php \Drupal\media_directories_ui\Form\MediaEditForm::getTargetBundles()

Get the allowed target bundles from the form state.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

array All allowed target bundle names.

Overrides AddMediaFormBase::getTargetBundles

File

modules/media_directories_ui/src/Form/MediaEditForm.php, line 52

Class

MediaEditForm
Class MediaEditForm.

Namespace

Drupal\media_directories_ui\Form

Code

protected function getTargetBundles(FormStateInterface $form_state) {
  $medias = $form_state
    ->get('media');
  if (is_array($medias)) {
    $bundles = [];
    foreach ($medias as $media) {
      $bundles[] = $media
        ->bundle();
    }
    return $bundles;
  }
  return parent::getTargetBundles($form_state);
}