diff --git a/core/modules/system/tests/modules/action_test/src/Plugin/Action/SaveEntity.php b/core/modules/system/tests/modules/action_test/src/Plugin/Action/SaveEntity.php index e3d296f..98e94bd 100644 --- a/core/modules/system/tests/modules/action_test/src/Plugin/Action/SaveEntity.php +++ b/core/modules/system/tests/modules/action_test/src/Plugin/Action/SaveEntity.php @@ -7,7 +7,9 @@ namespace Drupal\action_test\Plugin\Action; +use Drupal\Core\Access\AccessResult; use Drupal\Core\Action\ActionBase; +use Drupal\Core\Session\AccountInterface; /** * Provides an operation to save user entities. @@ -27,4 +29,12 @@ public function execute($entity = NULL) { $entity->save(); } + /** + * {@inheritdoc} + */ + public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { + $result = AccessResult::allowedIfHasPermission($account, 'administer users', 'OR'); + return $return_as_object ? $result : $result->isAllowed(); + } + } diff --git a/core/modules/user/src/Plugin/views/access/Role.php b/core/modules/user/src/Plugin/views/access/Role.php index d821b11..6aa955d 100644 --- a/core/modules/user/src/Plugin/views/access/Role.php +++ b/core/modules/user/src/Plugin/views/access/Role.php @@ -8,6 +8,7 @@ namespace Drupal\user\Plugin\views\access; use Drupal\Component\Utility\String; +use Drupal\Core\Access\AccessResult; use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\access\AccessPluginBase; use Symfony\Component\Routing\Route; @@ -34,8 +35,9 @@ class Role extends AccessPluginBase { /** * {@inheritdoc} */ - public function access(AccountInterface $account) { - return array_intersect(array_filter($this->options['role']), $account->getRoles()); + public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { + $result = AccessResult::allowedIf((bool) array_intersect(array_filter($this->options['role']), $account->getRoles())); + return $return_as_object ? $result : $result->isAllowed(); } /**