diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 65a32b2..de528a8 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -6,9 +6,9 @@ */ use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Session\AccountInterface; use Drupal\Core\Template\Attribute; use Drupal\filter\FilterFormatInterface; -use Drupal\user\UserInterface; /** * Non-HTML markup language filters that generate HTML. @@ -186,7 +186,7 @@ function filter_permission() { /** * Retrieves a list of enabled text formats, ordered by weight. * - * @param \Drupal\user\UserInterface|null $account + * @param \Drupal\Core\Session\AccountInterface|null $account * (optional) If provided, only those formats that are allowed for this user * account will be returned. All enabled formats will be returned otherwise. * Defaults to NULL. @@ -197,7 +197,7 @@ function filter_permission() { * * @see filter_formats_reset() */ -function filter_formats(UserInterface $account = NULL) { +function filter_formats(AccountInterface $account = NULL) { $formats = &drupal_static(__FUNCTION__, array()); if (!isset($formats['all'])) { @@ -290,18 +290,18 @@ function filter_get_formats_by_role($rid) { * returned by filter_fallback_format() should be used, since that is intended * to be a safe, consistent format that is always available to all users. * - * @param \Drupal\user\UserInterface $account + * @param \Drupal\Core\Session\AccountInterface|null $account * (optional) The user account to check. Defaults to the currently logged-in * user. Defaults to NULL. * - * @return + * @return string * The ID of the user's default text format. * * @see filter_fallback_format() */ -function filter_default_format(UserInterface $account = NULL) { +function filter_default_format(AccountInterface $account = NULL) { if (!isset($account)) { - $account = user_load($GLOBALS['user']->uid) ?: NULL; + $account = Drupal::request()->attributes->get('account'); } // Get a list of formats for this user, ordered by weight. The first one // available is the user's default format. @@ -717,7 +717,7 @@ function filter_process_format($element) { ); // Get a list of formats that the current user has access to. - $account = user_load($GLOBALS['user']->uid) ?: NULL; + $account = Drupal::request()->attributes->get('account'); $formats = filter_formats($account); // Use the default format for this user if none was selected. @@ -868,7 +868,7 @@ function theme_text_format_wrapper($variables) { * - id: Filter ID. */ function _filter_tips($format_id, $long = FALSE) { - $account = user_load($GLOBALS['user']->uid) ?: NULL; + $account = Drupal::request()->attributes->get('account'); $formats = filter_formats($account); $tips = array(); diff --git a/core/modules/filter/filter.routing.yml b/core/modules/filter/filter.routing.yml index 54d9278..2260177 100644 --- a/core/modules/filter/filter.routing.yml +++ b/core/modules/filter/filter.routing.yml @@ -38,5 +38,8 @@ filter_admin_disable: pattern: '/admin/config/content/formats/manage/{filter_format}/disable' defaults: _entity_form: 'filter_format.disable' + options: + _access_mode: 'ALL' requirements: _filter_disable_format_access: 'TRUE' + _permission: 'administer filters' diff --git a/core/modules/filter/lib/Drupal/filter/Access/FormatDisableCheck.php b/core/modules/filter/lib/Drupal/filter/Access/FormatDisableCheck.php index 051daf7..368aa97 100644 --- a/core/modules/filter/lib/Drupal/filter/Access/FormatDisableCheck.php +++ b/core/modules/filter/lib/Drupal/filter/Access/FormatDisableCheck.php @@ -24,14 +24,11 @@ public function appliesTo() { } /** - * Implements \Drupal\Core\Access\AccessCheckInterface::access(). + * {@inheritdoc} */ public function access(Route $route, Request $request) { - if ($format = $request->attributes->get('filter_format')) { - return user_access('administer filters') && !$format->isFallbackFormat(); - } - - return FALSE; + $format = $request->attributes->get('filter_format'); + return ($format && !$format->isFallbackFormat()) ? static::ALLOW : static::DENY; } } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php index aac39fc..1548360 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php @@ -26,10 +26,6 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A return TRUE; } - if (user_access('administer filters', $account)) { - return TRUE; - } - // Check the permission if one exists; otherwise, we have a non-existent // format so we return FALSE. $permission = $entity->getPermissionName();