function MediaLibraryUiBuilder::buildMediaLibraryView
Same name in other branches
- 9 core/modules/media_library/src/MediaLibraryUiBuilder.php \Drupal\media_library\MediaLibraryUiBuilder::buildMediaLibraryView()
- 8.9.x core/modules/media_library/src/MediaLibraryUiBuilder.php \Drupal\media_library\MediaLibraryUiBuilder::buildMediaLibraryView()
- 11.x core/modules/media_library/src/MediaLibraryUiBuilder.php \Drupal\media_library\MediaLibraryUiBuilder::buildMediaLibraryView()
Get the media library view.
Parameters
\Drupal\media_library\MediaLibraryState $state: The current state of the media library, derived from the current request.
Return value
array The render array for the media library view.
1 call to MediaLibraryUiBuilder::buildMediaLibraryView()
- MediaLibraryUiBuilder::buildLibraryContent in core/
modules/ media_library/ src/ MediaLibraryUiBuilder.php - Build the media library content area.
File
-
core/
modules/ media_library/ src/ MediaLibraryUiBuilder.php, line 327
Class
- MediaLibraryUiBuilder
- Service which builds the media library.
Namespace
Drupal\media_libraryCode
protected function buildMediaLibraryView(MediaLibraryState $state) {
// @todo Make the view configurable in
// https://www.drupal.org/project/drupal/issues/2971209
$view = $this->entityTypeManager
->getStorage('view')
->load('media_library');
$view_executable = $this->viewsExecutableFactory
->get($view);
$display_id = $state->get('views_display_id', 'widget');
// Make sure the state parameters are set in the request so the view can
// pass the parameters along in the pager, filters etc.
$view_request = $view_executable->getRequest();
$view_request->query
->add($state->all());
$view_executable->setRequest($view_request);
$args = [
$state->getSelectedTypeId(),
];
$view_executable->setDisplay($display_id);
$view_executable->preExecute($args);
$view_executable->execute($display_id);
return $view_executable->buildRenderable($display_id, $args, FALSE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.