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 220

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;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.