function AddFormBase::getPreSelectedMediaItems

Same name in other branches
  1. 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getPreSelectedMediaItems()
  2. 8.9.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getPreSelectedMediaItems()
  3. 11.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getPreSelectedMediaItems()

Get all pre-selected 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 pre-selected media items keyed by ID.

2 calls to AddFormBase::getPreSelectedMediaItems()
AddFormBase::buildCurrentSelectionArea in core/modules/media_library/src/Form/AddFormBase.php
Returns a render array containing the current selection.
AddFormBase::getCurrentMediaItems in core/modules/media_library/src/Form/AddFormBase.php
Get all pre-selected and added media items from the form state.

File

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

Class

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

Namespace

Drupal\media_library\Form

Code

protected function getPreSelectedMediaItems(FormStateInterface $form_state) {
    // Get the pre-selected media items from the form state.
    // @see ::processInputValues()
    return $form_state->get('current_selection') ?: [];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.