function UserHooks::filterFormatDisable

Implements hook_filter_format_disable().

Attributes

#[Hook('filter_format_disable')]

File

core/modules/user/src/Hook/UserHooks.php, line 451

Class

UserHooks
Hook implementations for user.

Namespace

Drupal\user\Hook

Code

public function filterFormatDisable(FilterFormatInterface $filter_format) : void {
  // Remove the permission from any roles.
  $permission = $filter_format->getPermissionName();
  /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $role_storage */
  $role_storage = \Drupal::entityTypeManager()->getStorage('user_role');
  /** @var \Drupal\user\Entity\Role $role */
  foreach ($role_storage->loadMultipleOverrideFree() as $role) {
    if ($role->hasPermission($permission)) {
      $role->revokePermission($permission)
        ->save();
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.