function WorkspaceSwitcherBlock::build

Same name in other branches
  1. 8.9.x core/modules/workspaces/src/Plugin/Block/WorkspaceSwitcherBlock.php \Drupal\workspaces\Plugin\Block\WorkspaceSwitcherBlock::build()
  2. 10 core/modules/workspaces/src/Plugin/Block/WorkspaceSwitcherBlock.php \Drupal\workspaces\Plugin\Block\WorkspaceSwitcherBlock::build()
  3. 11.x core/modules/workspaces/src/Plugin/Block/WorkspaceSwitcherBlock.php \Drupal\workspaces\Plugin\Block\WorkspaceSwitcherBlock::build()

Overrides BlockPluginInterface::build

File

core/modules/workspaces/src/Plugin/Block/WorkspaceSwitcherBlock.php, line 73

Class

WorkspaceSwitcherBlock
Provides a 'Workspace switcher' block.

Namespace

Drupal\workspaces\Plugin\Block

Code

public function build() {
    $build = [
        'form' => $this->formBuilder
            ->getForm(WorkspaceSwitcherForm::class),
        '#cache' => [
            'contexts' => $this->entityTypeManager
                ->getDefinition('workspace')
                ->getListCacheContexts(),
            'tags' => $this->entityTypeManager
                ->getDefinition('workspace')
                ->getListCacheTags(),
        ],
    ];
    return $build;
}

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