getAttachedAssets example

public function testAnnounceCommand($message$priority, array $expected) {
    if ($priority === NULL) {
      $command = new AnnounceCommand($message);
    }
    else {
      $command = new AnnounceCommand($message$priority);
    }

    $expected_assets = new AttachedAssets();
    $expected_assets->setLibraries(['core/drupal.announce']);

    $this->assertEquals($expected_assets$command->getAttachedAssets());
    $this->assertSame($expected$command->render());
  }

  /** * Data provider for testAnnounceCommand(). */
  public function announceCommandProvider() {
    return [
      'no priority' => [
        'Things are going to change!',
        NULL,
        [

  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 = BubbleableMetadata::mergeAttachments($this->getAttachments()$attachments);
      $this->setAttachments($attachments);
    }

    return $this;
  }

  
Home | Imprint | This part of the site doesn't use cookies.