// https://www.drupal.org/project/drupal/issues/3029227
$menu =
[ '#theme' => 'links__media_library_menu',
'#links' =>
[],
'#attributes' =>
[ 'class' =>
['js-media-library-menu'
],
],
];
$allowed_types =
$this->entityTypeManager->
getStorage('media_type'
)->
loadMultiple($allowed_type_ids);
$selected_type_id =
$state->
getSelectedTypeId();
foreach ($allowed_types as $allowed_type_id =>
$allowed_type) { $link_state = MediaLibraryState::
create($state->
getOpenerId(),
$state->
getAllowedTypeIds(),
$allowed_type_id,
$state->
getAvailableSlots(),
$state->
getOpenerParameters());
// Add the 'media_library_content' parameter so the response will contain
// only the updated content for the tab.
// @see self::buildUi()
$link_state->
set('media_library_content', 1
);
$title =
$allowed_type->
label();
$display_title =
[ '#markup' =>
$this->
t('<span class="visually-hidden">Show </span>@title<span class="visually-hidden"> media</span>',
['@title' =>
$title]),
];