toolbar_toolbar()
Implements hook_toolbar().
File
- core/modules/toolbar/toolbar.module, line 137
- Administration toolbar for quick access to top level administration items.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | function toolbar_toolbar() { // The 'Home' tab is a simple link, with no corresponding tray. $items [ 'home' ] = array ( '#type' => 'toolbar_item' , 'tab' => array ( '#type' => 'link' , '#title' => t( 'Back to site' ), '#url' => Url::fromRoute( '<front>' ), '#attributes' => array ( 'title' => t( 'Return to site content' ), 'class' => array ( 'toolbar-icon' , 'toolbar-icon-escape-admin' ), 'data-toolbar-escape-admin' => TRUE, ), ), '#wrapper_attributes' => array ( 'class' => array ( 'hidden' , 'home-toolbar-tab' ), ), '#attached' => array ( 'library' => array ( 'toolbar/toolbar.escapeAdmin' , ), ), '#weight' => -20, ); // To conserve bandwidth, we only include the top-level links in the HTML. // The subtrees are fetched through a JSONP script that is generated at the // toolbar_subtrees route. We provide the JavaScript requesting that JSONP // script here with the hash parameter that is needed for that route. // @see toolbar_subtrees_jsonp() list( $hash , $hash_cacheability ) = _toolbar_get_subtrees_hash(); $subtrees_attached [ 'drupalSettings' ][ 'toolbar' ] = [ 'subtreesHash' => $hash , ]; // The administration element has a link that is themed to correspond to // a toolbar tray. The tray contains the full administrative menu of the site. $items [ 'administration' ] = array ( '#type' => 'toolbar_item' , 'tab' => array ( '#type' => 'link' , '#title' => t( 'Manage' ), '#url' => Url::fromRoute( 'system.admin' ), '#attributes' => array ( 'title' => t( 'Admin menu' ), 'class' => array ( 'toolbar-icon' , 'toolbar-icon-menu' ), // A data attribute that indicates to the client to defer loading of // the admin menu subtrees until this tab is activated. Admin menu // subtrees will not render to the DOM if this attribute is removed. // The value of the attribute is intentionally left blank. Only the // presence of the attribute is necessary. 'data-drupal-subtrees' => '' , ), ), 'tray' => array ( '#heading' => t( 'Administration menu' ), '#attached' => $subtrees_attached , 'toolbar_administration' => array ( '#pre_render' => array ( 'toolbar_prerender_toolbar_administration_tray' , ), '#type' => 'container' , '#attributes' => array ( 'class' => array ( 'toolbar-menu-administration' ), ), ), ), '#weight' => -15, ); $hash_cacheability ->applyTo( $items [ 'administration' ]); return $items ; } |
Please login to continue.