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);
} /**
* AJAX callback to send the new media item(s) to the calling code.
*
* @param array $form
* The complete form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current form state.
*
* @return array|\Drupal\Core\Ajax\AjaxResponse
* The form array when there are form errors or an AJAX response to select
* the created items in the media library.
*/