function PageActions::build

Overrides TopBarItemBase::build

File

core/modules/navigation/src/Plugin/TopBarItem/PageActions.php, line 42

Class

PageActions
Provides the Page Actions basic top bar item.

Namespace

Drupal\navigation\Plugin\TopBarItem

Code

public function build() : array {
    $build = [];
    // Local tasks for content entities.
    if ($this->navigationRenderer
        ->hasLocalTasks()) {
        $local_tasks = $this->navigationRenderer
            ->getLocalTasks();
        $build = [
            '#theme' => 'top_bar_local_tasks',
            '#local_tasks' => $local_tasks['tasks'],
        ];
        assert($local_tasks['cacheability'] instanceof CacheableMetadata);
        $local_tasks['cacheability']->applyTo($build);
    }
    return $build;
}

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