You are here

protected function AddFormBase::buildMediaLibraryUi 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::buildMediaLibraryUi()

Build the render array of the media library UI.

Parameters

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

Return value

array The render array for the media library.

2 calls to AddFormBase::buildMediaLibraryUi()
AddFormBase::updateFormCallback in core/modules/media_library/src/Form/AddFormBase.php
AJAX callback to update the entire form based on source field input.
AddFormBase::updateLibrary in core/modules/media_library/src/Form/AddFormBase.php
AJAX callback to send the new media item(s) to the media library.

File

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

Class

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

Namespace

Drupal\media_library\Form

Code

protected function buildMediaLibraryUi(FormStateInterface $form_state) {

  // Get the render array for the media library. The media library state might
  // contain the 'media_library_content' when it has been opened from a
  // vertical tab. We need to remove that to make sure the render array
  // contains the vertical tabs. Besides that, we also need to force the media
  // library to create a new instance of the media add form.
  // @see \Drupal\media_library\MediaLibraryUiBuilder::buildMediaTypeAddForm()
  $state = $this
    ->getMediaLibraryState($form_state);
  $state
    ->remove('media_library_content');
  $state
    ->set('_media_library_form_rebuild', TRUE);
  return $this->libraryUiBuilder
    ->buildUi($state);
}