public function RoleSectionStorage::getRoles in Workbench Access 8
Gets a list of roles assigned to a section.
Parameters
\Drupal\workbench_access\Entity\AccessSchemeInterface $scheme: Access scheme.
string $id: The section id.
Return value
array An array of role ids
Overrides RoleSectionStorageInterface::getRoles
File
- src/
RoleSectionStorage.php, line 151
Class
- RoleSectionStorage
- Defines a role-section storage that uses the State API.
Namespace
Drupal\workbench_accessCode
public function getRoles(AccessSchemeInterface $scheme, $id) {
$roles = [];
$query = $this
->sectionStorage()
->getAggregateQuery()
->condition('access_scheme', $scheme
->id())
->condition('section_id', $id)
->groupBy('role_id.target_id')
->execute();
$rids = array_column($query, 'role_id_target_id');
if (!empty(current($rids))) {
$roles = $this->roleStorage
->loadMultiple($rids);
}
// @TODO: filter by permission?
return array_keys($roles);
}