You are here

protected function AddFormBase::getAddedMediaItems in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getAddedMediaItems()
  2. 10 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getAddedMediaItems()

Get all 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 the added media items keyed by delta. The media items won't have an ID until they are saved in ::submitForm().

5 calls to AddFormBase::getAddedMediaItems()
AddFormBase::buildForm in core/modules/media_library/src/Form/AddFormBase.php
Form constructor.
AddFormBase::getCurrentMediaItems in core/modules/media_library/src/Form/AddFormBase.php
Get all pre-selected and added media items from the form state.
AddFormBase::submitForm in core/modules/media_library/src/Form/AddFormBase.php
Form submission handler.
AddFormBase::updateLibrary in core/modules/media_library/src/Form/AddFormBase.php
AJAX callback to send the new media item(s) to the media library.
AddFormBase::validateForm in core/modules/media_library/src/Form/AddFormBase.php
Form validation handler.

File

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

Class

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

Namespace

Drupal\media_library\Form

Code

protected function getAddedMediaItems(FormStateInterface $form_state) {
  return $form_state
    ->get('media') ?: [];
}