class SetSubtreesCommand

Same name in other branches
  1. 9 core/modules/toolbar/src/Ajax/SetSubtreesCommand.php \Drupal\toolbar\Ajax\SetSubtreesCommand
  2. 8.9.x core/modules/toolbar/src/Ajax/SetSubtreesCommand.php \Drupal\toolbar\Ajax\SetSubtreesCommand
  3. 11.x 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

File

core/modules/toolbar/src/Ajax/SetSubtreesCommand.php, line 10

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

Title Sort descending Modifiers Object type Summary Overriden Title
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.

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