You are here

protected function MediaDirectoriesController::addMessagesToResponse in Media Directories 2.x

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

Adds a PrependCommad to an ajax response rendering the current status messages.

Parameters

\Drupal\Core\Ajax\AjaxResponse $response: The response.

string $selector: A jQuery selector.

7 calls to MediaDirectoriesController::addMessagesToResponse()
MediaDirectoriesController::directoryDelete in modules/media_directories_ui/src/Controller/MediaDirectoriesController.php
Delete directory.
MediaDirectoriesController::directoryMove in modules/media_directories_ui/src/Controller/MediaDirectoriesController.php
Move directory to different directory.
MediaDirectoriesController::directoryRename in modules/media_directories_ui/src/Controller/MediaDirectoriesController.php
Rename directory.
MediaDirectoriesController::mediaAdd in modules/media_directories_ui/src/Controller/MediaDirectoriesController.php
New media entity add form.
MediaDirectoriesController::mediaDelete in modules/media_directories_ui/src/Controller/MediaDirectoriesController.php
Media entity delete confirmation form.

... See full list

File

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

Class

MediaDirectoriesController
Main controller class.

Namespace

Drupal\media_directories_ui\Controller

Code

protected function addMessagesToResponse(AjaxResponse $response, $selector = '.entity-browser-form') {
  $status_messages = [
    '#type' => 'status_messages',
  ];
  $messages = $this->renderer
    ->renderRoot($status_messages);
  if (!empty($messages)) {
    $response
      ->addCommand(new PrependCommand($selector, $messages));
  }
}