You are here

class WorkbenchToolbar in Workbench 8

Generates the toolbar elements for Workbench.

Hierarchy

Expanded class hierarchy of WorkbenchToolbar

1 file declares its use of WorkbenchToolbar
workbench.module in ./workbench.module
Workbench module file.

File

src/Render/Element/WorkbenchToolbar.php, line 11

Namespace

Drupal\workbench\Render\Element
View source
class WorkbenchToolbar implements TrustedCallbackInterface {

  /**
   * {@inheritdoc}
   */
  public static function trustedCallbacks() {
    return [
      'preRenderTray',
    ];
  }

  /**
   * Render the Workbench toolbar tray.
   *
   * @param array $element
   *   The tray render array.
   *
   * @return array
   *   The tray render array with the Workbench items added.
   *
   * @see toolbar_prerender_toolbar_administration_tray()
   * @see drupal_render()
   */
  public static function preRenderTray(array $element) {
    $menu_tree = \Drupal::service('toolbar.menu_tree');
    $parameters = new MenuTreeParameters();
    $parameters
      ->setMinDepth(1)
      ->setMaxDepth(1);
    $tree = $menu_tree
      ->load('workbench', $parameters);
    $manipulators = [
      [
        'callable' => 'menu.default_tree_manipulators:checkAccess',
      ],
      [
        'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
      ],
      [
        'callable' => 'toolbar_menu_navigation_links',
      ],
    ];
    $tree = $menu_tree
      ->transform($tree, $manipulators);
    $element['administration_menu'] = $menu_tree
      ->build($tree);
    return $element;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.
WorkbenchToolbar::preRenderTray public static function Render the Workbench toolbar tray.
WorkbenchToolbar::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks