diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php index ff6217d..bdf6b3c 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php @@ -23,7 +23,7 @@ * id = "field_instance_config", * label = @Translation("Field instance"), * controllers = { - * "access" = "Drupal\field\FieldInstanceConfigAccessController", + * "access" = "Drupal\field\FieldInstanceConfigAccessHandler", * "storage" = "Drupal\field\FieldInstanceConfigStorage" * }, * config_prefix = "instance", diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceConfigAccessController.php b/core/modules/field/lib/Drupal/field/FieldInstanceConfigAccessHandler.php similarity index 61% rename from core/modules/field/lib/Drupal/field/FieldInstanceConfigAccessController.php rename to core/modules/field/lib/Drupal/field/FieldInstanceConfigAccessHandler.php index b28fd8a..53f08ee 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceConfigAccessController.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceConfigAccessHandler.php @@ -2,19 +2,21 @@ /** * @file - * Contains \Drupal\field\FieldInstanceConfigAccessController. + * Contains \Drupal\field\FieldInstanceConfigAccessHandler. */ namespace Drupal\field; -use Drupal\Core\Entity\EntityAccessController; +use Drupal\Core\Entity\EntityAccessHandler; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; /** - * Defines the access controller for the field instance entity type. + * Defines the access handler for the field instance entity type. + * + * @see \Drupal\field\Entity\FieldInstanceConfig */ -class FieldInstanceConfigAccessController extends EntityAccessController { +class FieldInstanceConfigAccessHandler extends EntityAccessHandler { /** * {@inheritdoc} diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatAccess.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAccess.php deleted file mode 100644 index b6f6f58..0000000 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatAccess.php +++ /dev/null @@ -1,46 +0,0 @@ -isFallbackFormat() || $account->hasPermission($filter_format->getPermissionName()); - } - - // The fallback format may not be disabled. - if ($operation == 'disable' && $filter_format->isFallbackFormat()) { - return FALSE; - } - - // We do not allow filter formats to be deleted through the UI, because that - // would render any content that uses them unusable. - if ($operation == 'delete') { - return FALSE; - } - - if (in_array($operation, array('disable', 'update'))) { - return parent::checkAccess($filter_format, $operation, $langcode, $account); - } - } - -} diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessHandler.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessHandler.php index be63ac4..aa34a41 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessHandler.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessHandler.php @@ -21,26 +21,28 @@ class FilterFormatAccessHandler extends EntityAccessHandler { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - // Handle special cases up front. All users have access to the fallback - // format. - if ($operation == 'view' && $entity->isFallbackFormat()) { - return TRUE; + protected function checkAccess(EntityInterface $filter_format, $operation, $langcode, AccountInterface $account) { + /** @var \Drupal\filter\FilterFormatInterface $filter_format */ + + // All users are allowed to use the fallback filter. + if ($operation == 'use') { + return $filter_format->isFallbackFormat() || $account->hasPermission($filter_format->getPermissionName()); + } + + // The fallback format may not be disabled. + if ($operation == 'disable' && $filter_format->isFallbackFormat()) { + return FALSE; } + // We do not allow filter formats to be deleted through the UI, because that // would render any content that uses them unusable. if ($operation == 'delete') { return FALSE; } - if ($operation != 'view' && parent::checkAccess($entity, $operation, $langcode, $account)) { - return TRUE; + if (in_array($operation, array('disable', 'update'))) { + return parent::checkAccess($filter_format, $operation, $langcode, $account); } - - // Check the permission if one exists; otherwise, we have a non-existent - // format so we return FALSE. - $permission = $entity->getPermissionName(); - return !empty($permission) && $account->hasPermission($permission); } } diff --git a/core/scripts/switch-psr4.sh b/core/scripts/switch-psr4.sh index 07b6826..73bf011 100644 --- a/core/scripts/switch-psr4.sh +++ b/core/scripts/switch-psr4.sh @@ -8,7 +8,7 @@ * Moves module-provided class files to their PSR-4 location. * * E.g.: - * core/modules/action/{lib/Drupal/action → src}/ActionAccessController.php + * core/modules/action/{lib/Drupal/action → src}/ActionAccessHandler.php * core/modules/action/{lib/Drupal/action → src}/ActionAddForm.php */ diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index b4a019b..a9334bc 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -380,7 +380,7 @@ public function testBundle() { * @covers ::access */ public function testAccess() { - $access = $this->getMock('\Drupal\Core\Entity\EntityAccessControllerInterface'); + $access = $this->getMock('\Drupal\Core\Entity\EntityAccessHandlerInterface'); $operation = $this->randomName(); $access->expects($this->at(0)) ->method('access') @@ -390,7 +390,7 @@ public function testAccess() { ->method('createAccess') ->will($this->returnValue(TRUE)); $this->entityManager->expects($this->exactly(2)) - ->method('getAccessController') + ->method('getAccessHandler') ->will($this->returnValue($access)); $this->assertTrue($this->entity->access($operation)); $this->assertTrue($this->entity->access('create')); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index 6ccad14..d8766a6 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -216,7 +216,7 @@ public function testLabel() { * @covers ::access */ public function testAccess() { - $access = $this->getMock('\Drupal\Core\Entity\EntityAccessControllerInterface'); + $access = $this->getMock('\Drupal\Core\Entity\EntityAccessHandlerInterface'); $operation = $this->randomName(); $access->expects($this->at(0)) ->method('access') @@ -226,7 +226,7 @@ public function testAccess() { ->method('createAccess') ->will($this->returnValue(TRUE)); $this->entityManager->expects($this->exactly(2)) - ->method('getAccessController') + ->method('getAccessHandler') ->will($this->returnValue($access)); $this->assertTrue($this->entity->access($operation)); $this->assertTrue($this->entity->access('create'));