filter_get_roles_by_format

filter_get_roles_by_format(FilterFormatInterface $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.

File

core/modules/filter/filter.module, line 148
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();
}
doc_Drupal
2016-10-29 09:14:55
Comments
Leave a Comment

Please login to continue.