Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NavigationRenderer.php

function NavigationRenderer::removeLocalTasks

Alter the build of any local_tasks_block plugin block.

If we are showing the local tasks in the top bar, hide the local tasks from display to avoid duplicating the links.

Parameters

array $build: A renderable array representing the local_tasks_block plugin block to be rendered.

\Drupal\Core\Block\BlockPluginInterface $block: Block plugin object representing a local_tasks_block.

See also

navigation_block_build_local_tasks_block_alter()

File

core/modules/navigation/src/NavigationRenderer.php, line 245

Class

NavigationRenderer
Handle rendering for different pieces of the navigation.

Namespace

Drupal\navigation

Code

public function removeLocalTasks(array &$build, BlockPluginInterface $block) : void {
    if ($block->getPluginId() !== 'local_tasks_block') {
        return;
    }
    if ($this->hasLocalTasks() && $this->moduleHandler
        ->moduleExists('navigation_top_bar')) {
        $build['#access'] = FALSE;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal