function 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();
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!filter!filter.module/function/filter_get_roles_by_format/8.1.x