You are here

class SetSubtreesCommand in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/toolbar/src/Ajax/SetSubtreesCommand.php \Drupal\toolbar\Ajax\SetSubtreesCommand

Defines an AJAX command that sets the toolbar subtrees.

Hierarchy

Expanded class hierarchy of SetSubtreesCommand

1 file declares its use of SetSubtreesCommand
ToolbarController.php in core/modules/toolbar/src/Controller/ToolbarController.php
Contains \Drupal\toolbar\Controller\ToolbarController.

File

core/modules/toolbar/src/Ajax/SetSubtreesCommand.php, line 15
Contains \Drupal\toolbar\Ajax\SetSubtreesCommand.

Namespace

Drupal\toolbar\Ajax
View source
class SetSubtreesCommand implements CommandInterface {

  /**
   * The toolbar subtrees.
   *
   * @var array
   */
  protected $subtrees;

  /**
   * Constructs a SetSubtreesCommand object.
   *
   * @param array $subtrees
   *   The toolbar subtrees that will be set.
   */
  public function __construct($subtrees) {
    $this->subtrees = $subtrees;
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    return [
      'command' => 'setToolbarSubtrees',
      'subtrees' => array_map('strval', $this->subtrees),
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SetSubtreesCommand::$subtrees protected property The toolbar subtrees.
SetSubtreesCommand::render public function Return an array to be run through json_encode and sent to the client. Overrides CommandInterface::render
SetSubtreesCommand::__construct public function Constructs a SetSubtreesCommand object.