function MetaEventSubscriber::currentUserHasAdminRole
Return value
string
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to MetaEventSubscriber::currentUserHasAdminRole()
- MetaEventSubscriber::addRelationshipMeta in core/
modules/ jsonapi/ tests/ modules/ jsonapi_test_meta_events/ src/ EventSubscriber/ MetaEventSubscriber.php - MetaEventSubscriber::addResourceObjectMeta in core/
modules/ jsonapi/ tests/ modules/ jsonapi_test_meta_events/ src/ EventSubscriber/ MetaEventSubscriber.php
File
-
core/
modules/ jsonapi/ tests/ modules/ jsonapi_test_meta_events/ src/ EventSubscriber/ MetaEventSubscriber.php, line 144
Class
- MetaEventSubscriber
- Event subscriber which tests adding metadata to ResourceObjects and relationships.
Namespace
Drupal\jsonapi_test_meta_events\EventSubscriberCode
protected function currentUserHasAdminRole() : string {
$admin_roles = \Drupal::entityTypeManager()->getStorage('user_role')
->loadByProperties([
'is_admin' => TRUE,
]);
$has_admin_role = 'yes';
if (count(array_intersect(\Drupal::currentUser()->getRoles(), array_keys($admin_roles))) === 0) {
$has_admin_role = 'no';
}
return $has_admin_role;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.