FilterPermissions::permissions

public FilterPermissions::permissions()

Returns an array of filter permissions.

Return value

array

File

core/modules/filter/src/FilterPermissions.php, line 46

Class

FilterPermissions
Provides dynamic permissions of the filter module.

Namespace

Drupal\filter

Code

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 */
  $formats = $this->entityManager->getStorage('filter_format')->loadByProperties(['status' => TRUE]);
  uasort($formats, 'Drupal\Core\Config\Entity\ConfigEntityBase::sort');
  foreach ($formats as $format) {
    if ($permission = $format->getPermissionName()) {
      $permissions[$permission] = [
        'title' => $this->t('Use the <a href=":url">@label</a> text format', [':url' => $format->url(), '@label' => $format->label()]),
        'description' => [
          '#prefix' => '<em>',
          '#markup' => $this->t('Warning: This permission may have security implications depending on how the text format is configured.'),
          '#suffix' => '</em>'
        ],
      ];
    }
  }
  return $permissions;
}
doc_Drupal
2016-10-29 09:14:50
Comments
Leave a Comment

Please login to continue.