class PermissionProvider in GraphQL 8.4
Provides access control permissions for all exposed GraphQL servers.
Hierarchy
- class \Drupal\graphql\PermissionProvider uses StringTranslationTrait
Expanded class hierarchy of PermissionProvider
1 string reference to 'PermissionProvider'
1 service uses PermissionProvider
File
- src/
PermissionProvider.php, line 11
Namespace
Drupal\graphqlView source
class PermissionProvider {
use StringTranslationTrait;
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* PermissionProvider constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->entityTypeManager = $entityTypeManager;
}
/**
* Collects permissions for the server endpoints.
*/
public function permissions() : array {
$storage = $this->entityTypeManager
->getStorage('graphql_server');
/** @var \Drupal\graphql\Entity\ServerInterface[] $servers */
$servers = $storage
->loadMultiple();
$permissions = [];
foreach ($servers as $id => $server) {
$params = [
'%name' => $server
->label(),
];
$permissions["execute {$id} arbitrary graphql requests"] = [
'title' => $this
->t('%name: Execute arbitrary requests', $params),
'description' => $this
->t('Allows users to execute arbitrary requests on the %name endpoint.', $params),
];
$permissions["execute {$id} persisted graphql requests"] = [
'title' => $this
->t('%name: Execute persisted requests', $params),
'description' => $this
->t('Allows users to execute persisted requests on the %name endpoint.', $params),
];
$permissions["use {$id} graphql explorer"] = [
'title' => $this
->t('%name: Use explorer', $params),
'description' => $this
->t('Allows users use the explorer interface.', $params),
];
$permissions["use {$id} graphql voyager"] = [
'title' => $this
->t('%name: Use voyager', $params),
'description' => $this
->t('Allows users to use the voyager interface.', $params),
];
}
return $permissions;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PermissionProvider:: |
protected | property | The entity type manager service. | |
PermissionProvider:: |
public | function | Collects permissions for the server endpoints. | |
PermissionProvider:: |
public | function | PermissionProvider constructor. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |