function AddFormBase::getCurrentMediaItems
Same name in other branches
- 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getCurrentMediaItems()
- 8.9.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getCurrentMediaItems()
- 11.x 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 877
Class
- AddFormBase
- Provides a base class for creating media items from within the media library.
Namespace
Drupal\media_library\FormCode
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.