class EntityTestPermissions in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/entity_test/src/EntityTestPermissions.php \Drupal\entity_test\EntityTestPermissions
- 9 core/modules/system/tests/modules/entity_test/src/EntityTestPermissions.php \Drupal\entity_test\EntityTestPermissions
Provides dynamic permissions for entity test.
Hierarchy
- class \Drupal\entity_test\EntityTestPermissions uses StringTranslationTrait
Expanded class hierarchy of EntityTestPermissions
File
- core/
modules/ system/ tests/ modules/ entity_test/ src/ EntityTestPermissions.php, line 11
Namespace
Drupal\entity_testView source
class EntityTestPermissions {
use StringTranslationTrait;
/**
* Returns an array of entity_test_bundle permissions.
*
* @return array
* An array of entity_test_bundle permissions.
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function entityTestBundlePermissions() {
$perms = [];
// Generate permissions for all EntityTestBundle bundles.
foreach (EntityTestBundle::loadMultiple() as $type) {
$perms += $this
->buildPermissions($type);
}
return $perms;
}
/**
* Returns a list of entity test permissions for a given entity test bundle.
*
* @param \Drupal\entity_test\Entity\EntityTestBundle $type
* The entity test bundle.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected function buildPermissions(EntityTestBundle $type) {
$type_id = $type
->id();
$type_params = [
'%type_name' => $type
->label(),
];
return [
"create {$type_id} entity_test_with_bundle entities" => [
'title' => $this
->t('%type_name: Create new entity', $type_params),
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityTestPermissions:: |
protected | function | Returns a list of entity test permissions for a given entity test bundle. | |
EntityTestPermissions:: |
public | function | Returns an array of entity_test_bundle permissions. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 3 |
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. | 1 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |