public function Permissions::avatarGenerators in Avatar Kit 8
Define permissions for picture providers.
Return value
array An array of permissions.
1 string reference to 'Permissions::avatarGenerators'
File
- src/
Permissions.php, line 48
Class
- Permissions
- Define a permission generator.
Namespace
Drupal\avatarsCode
public function avatarGenerators() {
$permissions = [];
/** @var \Drupal\avatars\AvatarGeneratorStorageInterface $avatars_generator_storage */
$avatars_generator_storage = \Drupal::entityTypeManager()
->getStorage('avatar_generator');
foreach ($avatars_generator_storage
->loadMultiple() as $instance) {
if ($instance
->getPlugin()
->getPluginId() == 'user_preference') {
continue;
}
$t_args = [
'%label' => $instance
->label(),
];
$permissions["avatars avatar_generator user " . $instance
->id()] = [
'title' => $this
->t('Use %label', $t_args),
'description' => $this
->t('User can select %label avatar generator.', $t_args),
];
}
return $permissions;
}