You are here

protected function AddFormBase::getCurrentMediaItems in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getCurrentMediaItems()

Get all pre-selected and added media items from the form state.

Parameters

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

Return value

\Drupal\media\MediaInterface[] An array containing all pre-selected and added media items with renumbered numeric keys.

1 call to AddFormBase::getCurrentMediaItems()
AddFormBase::updateWidget in core/modules/media_library/src/Form/AddFormBase.php
AJAX callback to send the new media item(s) to the calling code.

File

core/modules/media_library/src/Form/AddFormBase.php, line 838

Class

AddFormBase
Provides a base class for creating media items from within the media library.

Namespace

Drupal\media_library\Form

Code

protected function getCurrentMediaItems(FormStateInterface $form_state) {
  $pre_selected_media = $this
    ->getPreSelectedMediaItems($form_state);
  $added_media = $this
    ->getAddedMediaItems($form_state);

  // Using array_merge will renumber the numeric keys.
  return array_merge($pre_selected_media, $added_media);
}