public function CustomPermissions::permissions in Custom Permissions 8
Same name and namespace in other branches
- 8.2 src/CustomPermissions.php \Drupal\config_perms\CustomPermissions::permissions()
Returns an array of filter permissions.
Return value
array Return a table of permissions
1 string reference to 'CustomPermissions::permissions'
File
- src/
CustomPermissions.php, line 47
Class
- CustomPermissions
- Provides dynamic permissions of the filter module.
Namespace
Drupal\config_permsCode
public function permissions() {
$permissions = [];
// Generate permissions for each text format. Warn the administrator that
// any of them are potentially unsafe.
/** @var \Drupal\filter\FilterFormatInterface[] $formats */
$custom_perms = $this->entityManager
->getStorage('custom_perms_entity')
->loadByProperties([
'status' => TRUE,
]);
uasort($custom_perms, 'Drupal\\Core\\Config\\Entity\\ConfigEntityBase::sort');
foreach ($custom_perms as $custom_perm) {
if ($permission = $custom_perm
->label()) {
$permissions[$permission] = [
'title' => $permission,
'description' => [
'#prefix' => '<em>',
'#markup' => $this
->t('Warning: This permission may have security implications.'),
'#suffix' => '</em>',
],
];
}
}
return $permissions;
}