You are here

public function MediaDirectoriesController::directoryContent in Media Directories 8

Same name and namespace in other branches
  1. 2.x modules/media_directories_ui/src/Controller/MediaDirectoriesController.php \Drupal\media_directories_ui\Controller\MediaDirectoriesController::directoryContent()

Load directory content.

Inserts directory content into browser.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request.

Return value

\Drupal\Core\Ajax\AjaxResponse An AJAX response.

1 string reference to 'MediaDirectoriesController::directoryContent'
media_directories_ui.routing.yml in modules/media_directories_ui/media_directories_ui.routing.yml
modules/media_directories_ui/media_directories_ui.routing.yml

File

modules/media_directories_ui/src/Controller/MediaDirectoriesController.php, line 160

Class

MediaDirectoriesController
Main controller class.

Namespace

Drupal\media_directories_ui\Controller

Code

public function directoryContent(Request $request) {
  $response = new AjaxResponse();
  $directory_id = (int) $request->request
    ->get('directory_id');
  $target_bundles = $request->request
    ->get('target_bundles');
  $media_name_search = $request->request
    ->get('media_name');
  $bundles = $target_bundles ? implode('+', $target_bundles) : 'all';
  $view = views_embed_view('media_directories_base', 'media_browser', $directory_id, $bundles, $media_name_search);
  $response
    ->addCommand(new HtmlCommand('.browser--listing', $view));
  return $response;
}