diff core/modules/toolbar/src/Ajax/SetSubtreesCommand.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/toolbar/src/Ajax/SetSubtreesCommand.php	Wed Nov 29 16:09:58 2017 +0000
@@ -0,0 +1,39 @@
+<?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),
+    ];
+  }
+
+}