Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / toolbar / src / Ajax / SetSubtreesCommand.php
1 <?php
2
3 namespace Drupal\toolbar\Ajax;
4
5 use Drupal\Core\Ajax\CommandInterface;
6
7 /**
8  * Defines an AJAX command that sets the toolbar subtrees.
9  */
10 class SetSubtreesCommand implements CommandInterface {
11
12   /**
13    * The toolbar subtrees.
14    *
15    * @var array
16    */
17   protected $subtrees;
18
19   /**
20    * Constructs a SetSubtreesCommand object.
21    *
22    * @param array $subtrees
23    *   The toolbar subtrees that will be set.
24    */
25   public function __construct($subtrees) {
26     $this->subtrees = $subtrees;
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function render() {
33     return [
34       'command' => 'setToolbarSubtrees',
35       'subtrees' => array_map('strval', $this->subtrees),
36     ];
37   }
38
39 }