function AjaxResponse::mergeWith

Merges other ajax response with this one.

Adds commands and merges attachments from the other ajax response.

Parameters

\Drupal\Core\Ajax\AjaxResponse $other: An AJAX response to merge.

Return value

$this Returns this after merging.

File

core/lib/Drupal/Core/Ajax/AjaxResponse.php, line 69

Class

AjaxResponse
JSON response object for AJAX requests.

Namespace

Drupal\Core\Ajax

Code

public function mergeWith(AjaxResponse $other) : AjaxResponse {
  $this->commands = array_merge($this->getCommands(), $other->getCommands());
  $this->attachments = BubbleableMetadata::mergeAttachments($this->getAttachments(), $other->getAttachments());
  return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.