Chris@0: ' . t('About') . ''; Chris@0: $output .= '

' . t('The Place Blocks module allows you to place blocks from every page. For more information, see the online documentation for the Place Blocks module.', [':blocks-documentation' => 'https://www.drupal.org/documentation/modules/block_place/']) . '

'; Chris@0: $output .= '

' . t('Uses') . '

'; Chris@0: $output .= '

' . t('Block placement is specific to each theme on your site. This module allows you to place blocks in the context of your content pages.') . '

'; Chris@0: return $output; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_toolbar(). Chris@0: */ Chris@0: function block_place_toolbar() { Chris@0: // Link to the current page with a query parameter. Chris@0: $query = \Drupal::request()->query->all(); Chris@0: $wrapper_class = ''; Chris@0: $status_class = ''; Chris@0: $description = ''; Chris@0: if (isset($query['block-place'])) { Chris@0: $status_class = 'active'; Chris@0: $wrapper_class = 'is-active'; Chris@0: $description = t('Exit Place block mode.'); Chris@0: unset($query['block-place']); Chris@0: unset($query['destination']); Chris@0: } Chris@0: else { Chris@0: $status_class = 'inactive'; Chris@0: $description = t('Show regions to Place blocks.'); Chris@0: $query['block-place'] = '1'; Chris@0: // Setting destination is both a work-around for the toolbar "Back to site" Chris@0: // link in escapeAdmin.js and used for the destination after picking a Chris@0: // block. Chris@0: $query['destination'] = Url::fromRoute('')->toString(); Chris@0: } Chris@0: Chris@0: // Remove on Admin routes. Chris@0: $admin_route = \Drupal::service('router.admin_context')->isAdminRoute(); Chris@0: // Remove on Block Demo page. Chris@0: $admin_demo = \Drupal::routeMatch()->getRouteName() === 'block.admin_demo'; Chris@0: $access = (\Drupal::currentUser()->hasPermission('administer blocks') && !$admin_route && !$admin_demo); Chris@0: Chris@0: // The 'Place Block' tab is a simple link, with no corresponding tray. Chris@0: $items['block_place'] = [ Chris@0: '#cache' => [ Chris@0: 'contexts' => ['user.permissions', 'url.query_args'], Chris@0: ], Chris@0: '#type' => 'toolbar_item', Chris@0: 'tab' => [ Chris@0: '#access' => $access, Chris@0: '#type' => 'link', Chris@0: '#title' => t('Place block'), Chris@0: '#url' => Url::fromRoute('', [], ['query' => $query]), Chris@0: '#attributes' => [ Chris@0: 'title' => $description, Chris@0: 'class' => ['toolbar-icon', 'toolbar-icon-place-block-' . $status_class], Chris@0: ], Chris@0: ], Chris@0: '#wrapper_attributes' => [ Chris@0: 'class' => ['toolbar-tab', 'block-place-toolbar-tab', $wrapper_class], Chris@0: ], Chris@0: '#weight' => 100, Chris@0: '#attached' => [ Chris@0: 'library' => [ Chris@0: 'block_place/drupal.block_place.icons', Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: return $items; Chris@0: }