public function WebformAccessGroupStorage::getUserEntities in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_access/src/WebformAccessGroupStorage.php \Drupal\webform_access\WebformAccessGroupStorage::getUserEntities()
Get source entities associated with a user account.
Parameters
\Drupal\Core\Session\AccountInterface $account: A user account.
string|null $entity_type: Source entity type.
Return value
\Drupal\Core\Entity\EntityInterface[] Get source entities associated with a user account.
Overrides WebformAccessGroupStorageInterface::getUserEntities
File
- modules/
webform_access/ src/ WebformAccessGroupStorage.php, line 248
Class
- WebformAccessGroupStorage
- Storage controller class for "webform_access_group" configuration entities.
Namespace
Drupal\webform_accessCode
public function getUserEntities(AccountInterface $account, $entity_type = NULL) {
/** @var \Drupal\webform_access\WebformAccessGroupInterface[] $webform_access_groups */
$webform_access_groups = $this
->loadByEntities(NULL, NULL, $account);
$source_entity_ids = [];
foreach ($webform_access_groups as $webform_access_group) {
$entities = $webform_access_group
->getEntityIds();
foreach ($entities as $entity) {
list($source_entity_type, $source_entity_id) = explode(':', $entity);
if (!$entity_type || $source_entity_type === $entity_type) {
$source_entity_ids[] = $source_entity_id;
}
}
}
return $this->entityTypeManager
->getStorage($entity_type)
->loadMultiple($source_entity_ids);
}