You are here

class UserRoles in Open Social 10.3.x

Same name in this branch
  1. 10.3.x modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserRoles.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserRoles
  2. 10.3.x modules/social_features/social_user/src/Plugin/GraphQL/DataProducer/UserRoles.php \Drupal\social_user\Plugin\GraphQL\DataProducer\UserRoles
Same name and namespace in other branches
  1. 10.0.x modules/social_features/social_user/src/Plugin/GraphQL/DataProducer/UserRoles.php \Drupal\social_user\Plugin\GraphQL\DataProducer\UserRoles
  2. 10.1.x modules/social_features/social_user/src/Plugin/GraphQL/DataProducer/UserRoles.php \Drupal\social_user\Plugin\GraphQL\DataProducer\UserRoles
  3. 10.2.x modules/social_features/social_user/src/Plugin/GraphQL/DataProducer/UserRoles.php \Drupal\social_user\Plugin\GraphQL\DataProducer\UserRoles

Returns the roles for a user.

Plugin annotation


@DataProducer(
  id = "user_roles",
  name = @Translation("User roles"),
  description = @Translation("Returns the roles that a user has."),
  produces = @ContextDefinition("array",
    label = @Translation("User roles")
  ),
  consumes = {
    "user" = @ContextDefinition("entity:user",
      label = @Translation("User")
    )
  }
)

Hierarchy

  • class \Drupal\social_user\Plugin\GraphQL\DataProducer\UserRoles extends \Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase implements \Drupal\graphql\Plugin\DataProducerPluginCachingInterface

Expanded class hierarchy of UserRoles

File

modules/social_features/social_user/src/Plugin/GraphQL/DataProducer/UserRoles.php, line 26

Namespace

Drupal\social_user\Plugin\GraphQL\DataProducer
View source
class UserRoles extends DataProducerPluginBase implements DataProducerPluginCachingInterface {

  /**
   * Resolves the value for this data producer.
   *
   * @param \Drupal\user\UserInterface $user
   *   The user to get the roles for.
   *
   * @return string[]
   *   The roles the user has.
   */
  public function resolve(UserInterface $user) {
    return $user
      ->getRoles();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UserRoles::resolve public function Resolves the value for this data producer.