/**
  * Merges the values of another bubbleable metadata object with this one.
  *
  * @param \Drupal\Core\Render\BubbleableMetadata $other
  *   The other bubbleable metadata object.
  * @return static
  *   A new bubbleable metadata object, with the merged data.
  *
  * @todo Add unit test for this in
  *       \Drupal\Tests\Core\Render\BubbleableMetadataTest when
  *       drupal_merge_attached() no longer is a procedural function and remove
  *       the '@codeCoverageIgnore' annotation.
  */
 public function merge(BubbleableMetadata $other)
 {
     $result = new BubbleableMetadata();
     $result->contexts = Cache::mergeContexts($this->contexts, $other->contexts);
     $result->tags = Cache::mergeTags($this->tags, $other->tags);
     $result->maxAge = Cache::mergeMaxAges($this->maxAge, $other->maxAge);
     $result->attached = Renderer::mergeAttachments($this->attached, $other->attached);
     $result->postRenderCache = NestedArray::mergeDeep($this->postRenderCache, $other->postRenderCache);
     return $result;
 }
 /**
  * Add an AJAX command to the response.
  *
  * @param \Drupal\Core\Ajax\CommandInterface $command
  *   An AJAX command object implementing CommandInterface.
  * @param boolean $prepend
  *   A boolean which determines whether the new command should be executed
  *   before previously added commands. Defaults to FALSE.
  *
  * @return AjaxResponse
  *   The current AjaxResponse.
  */
 public function addCommand(CommandInterface $command, $prepend = FALSE)
 {
     if ($prepend) {
         array_unshift($this->commands, $command->render());
     } else {
         $this->commands[] = $command->render();
     }
     if ($command instanceof CommandWithAttachedAssetsInterface) {
         $assets = $command->getAttachedAssets();
         $attachments = ['library' => $assets->getLibraries(), 'drupalSettings' => $assets->getSettings()];
         $attachments = Renderer::mergeAttachments($this->attachments, $attachments);
         $this->setAttachments($attachments);
     }
     return $this;
 }