SetSubtreesCommand.php

Same filename and directory in other branches
  1. 9 core/modules/toolbar/src/Ajax/SetSubtreesCommand.php
  2. 8.9.x core/modules/toolbar/src/Ajax/SetSubtreesCommand.php
  3. 10 core/modules/toolbar/src/Ajax/SetSubtreesCommand.php

Namespace

Drupal\toolbar\Ajax

File

core/modules/toolbar/src/Ajax/SetSubtreesCommand.php

View source
<?php

namespace Drupal\toolbar\Ajax;

use Drupal\Core\Ajax\CommandInterface;

/**
 * Defines an AJAX command that sets the toolbar subtrees.
 */
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),
        ];
    }

}

Classes

Title Deprecated Summary
SetSubtreesCommand Defines an AJAX command that sets the toolbar subtrees.

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