public function AjaxResponse::addCommand

Add an AJAX command to the response.

Parameters

object $command: An AJAX command object implementing CommandInterface.

boolean $prepend: A boolean which determines whether the new command should be executed before previously added commands. Defaults to FALSE.

Return value

AjaxResponse The current AjaxResponse.

1 call to AjaxResponse::addCommand()
AjaxResponse::ajaxRender in drupal/core/lib/Drupal/Core/Ajax/AjaxResponse.php
Prepares the AJAX commands for sending back to the client.

File

drupal/core/lib/Drupal/Core/Ajax/AjaxResponse.php, line 37
Definition of Drupal\Core\Ajax\AjaxResponse.

Class

AjaxResponse
JSON response object for AJAX requests.

Namespace

Drupal\Core\Ajax

Code

public function addCommand($command, $prepend = FALSE) {
  if ($prepend) {
    array_unshift($this->commands, $command
      ->render());
  }
  else {
    $this->commands[] = $command
      ->render();
  }
  return $this;
}