You are here

protected function Toolbar::allWorkspaces in Workspace 8

Returns a list of all defined and accessible workspaces.

Note: This assumes that the total number of workspaces on the site is very small. If it's actually large this method will have memory issues.

Return value

WorkspaceInterface[]

1 call to Toolbar::allWorkspaces()
Toolbar::preRenderWorkspaceSwitcherForms in src/Toolbar.php
Prerender callback; Adds the workspace switcher forms to the render array.

File

src/Toolbar.php, line 224

Class

Toolbar
Service for hooks and utilities related to Toolbar integration.

Namespace

Drupal\workspace

Code

protected function allWorkspaces() {
  return array_filter($this->entityTypeManager
    ->getStorage('workspace')
    ->loadMultiple(), function (WorkspaceInterface $workspace) {
    return $workspace
      ->isPublished() && !$workspace
      ->getQueuedForDelete() && $workspace
      ->access('view', $this->currentUser);
  });
}