protected function BundlePermissionHandlerTrait::generatePermissions in Drupal 10
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/BundlePermissionHandlerTrait.php \Drupal\Core\Entity\BundlePermissionHandlerTrait::generatePermissions()
Builds a permissions array for the supplied bundles.
Parameters
\Drupal\Core\Entity\EntityInterface[] $bundles: An array of bundles to generate permissions for.
callable $permission_builder: A callable to generate the permissions for a particular bundle. Returns an array of permissions. See PermissionHandlerInterface::getPermissions() for the array structure.
Return value
array Permissions array. See PermissionHandlerInterface::getPermissions() for the array structure.
See also
\Drupal\user\PermissionHandlerInterface::getPermissions()
File
- core/
lib/ Drupal/ Core/ Entity/ BundlePermissionHandlerTrait.php, line 26
Class
- BundlePermissionHandlerTrait
- Provides a method to simplify generating bundle level permissions.
Namespace
Drupal\Core\EntityCode
protected function generatePermissions(array $bundles, callable $permission_builder) {
$permissions = [];
foreach ($bundles as $bundle) {
$permissions += array_map(function (array $perm) use ($bundle) {
// This permission is generated on behalf of a bundle, therefore
// add the bundle as a config dependency.
$perm['dependencies'][$bundle
->getConfigDependencyKey()][] = $bundle
->getConfigDependencyName();
return $perm;
}, $permission_builder($bundle));
}
return $permissions;
}