/** * {@inheritdoc} */ public function build() { $build = array(); $route_name = \Drupal::service('path.matcher')->isFrontPage() ? '<front>' : '<current>'; $links = $this->workspaceManager->getWorkspaceSwitchLinks(Url::fromRoute($route_name)); if (isset($links)) { $build = array('#theme' => 'links__workspace_block', '#links' => $links, '#attributes' => array('class' => array('workspace-switcher')), '#set_active_class' => TRUE, '#cache' => ['contexts' => $this->entityTypeManager->getDefinition('workspace')->getListCacheContexts(), 'tags' => $this->entityTypeManager->getDefinition('workspace')->getListCacheTags()]); } return $build; }