function filter_get_roles_by_format in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/filter/filter.module \filter_get_roles_by_format()
Retrieves a list of roles that are allowed to use a given text format.
Parameters
\Drupal\filter\FilterFormatInterface $format: An object representing the text format.
Return value
array An array of role names, keyed by role ID.
7 calls to filter_get_roles_by_format()
- FilterDefaultConfigTest::testInstallation in core/
modules/ filter/ src/ Tests/ FilterDefaultConfigTest.php - Tests installation of default formats.
- FilterDefaultConfigTest::testUpdateRoles in core/
modules/ filter/ src/ Tests/ FilterDefaultConfigTest.php - Tests that changes to FilterFormat::$roles do not have an effect.
- FilterFormatAccessTest::testFormatRoles in core/
modules/ filter/ src/ Tests/ FilterFormatAccessTest.php - Tests if text format is available to a role.
- FilterFormatEditForm::form in core/
modules/ filter/ src/ FilterFormatEditForm.php - Gets the actual form array to be built.
- FilterFormatFormBase::form in core/
modules/ filter/ src/ FilterFormatFormBase.php - Gets the actual form array to be built.
File
- core/
modules/ filter/ filter.module, line 149 - Framework for handling the filtering of content.
Code
function filter_get_roles_by_format(FilterFormatInterface $format) {
// Handle the fallback format upfront (all roles have access to this format).
if ($format
->isFallbackFormat()) {
return user_role_names();
}
// Do not list any roles if the permission does not exist.
$permission = $format
->getPermissionName();
return !empty($permission) ? user_role_names(FALSE, $permission) : array();
}