public function UserSectionStorage::getUserSections in Workbench Access 8
Gets the editorial sections assigned to a user.
Parameters
\Drupal\workbench_access\Entity\AccessSchemeInterface $scheme: Access scheme.
\Drupal\Core\Session\AccountInterface $account: An optional user. If not provided, the active user is returned.
bool $add_roles: Whether to add the role-based assignments to the user. Defaults to true.
Return value
array An array of section ids that the user is assigned to.
Overrides UserSectionStorageInterface::getUserSections
File
- src/
UserSectionStorage.php, line 74
Class
- UserSectionStorage
- Defines a class for storing and retrieving sections assigned to a user.
Namespace
Drupal\workbench_accessCode
public function getUserSections(AccessSchemeInterface $scheme, AccountInterface $account = NULL, $add_roles = TRUE) {
// Get the information from the account.
if (!$account) {
$account = $this->currentUser;
}
if (!isset($this->userSectionCache[$scheme
->id()][$account
->id()])) {
$user_sections = $this
->loadUserSections($scheme, $account);
// Merge in role data.
if ($add_roles) {
$user_sections = array_merge($user_sections, $this->roleSectionStorage
->getRoleSections($scheme, $account));
}
$this->userSectionCache[$scheme
->id()][$account
->id()] = $user_sections;
}
return $this->userSectionCache[$scheme
->id()][$account
->id()];
}