You are here

class MockQuickEditEntityFieldAccessCheck in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/quickedit/tests/modules/src/MockQuickEditEntityFieldAccessCheck.php \Drupal\quickedit_test\MockQuickEditEntityFieldAccessCheck
  2. 9 core/modules/quickedit/tests/modules/src/MockQuickEditEntityFieldAccessCheck.php \Drupal\quickedit_test\MockQuickEditEntityFieldAccessCheck

Access check for in-place editing entity fields.

Hierarchy

Expanded class hierarchy of MockQuickEditEntityFieldAccessCheck

1 file declares its use of MockQuickEditEntityFieldAccessCheck
MetadataGeneratorTest.php in core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php

File

core/modules/quickedit/tests/modules/src/MockQuickEditEntityFieldAccessCheck.php, line 12

Namespace

Drupal\quickedit_test
View source
class MockQuickEditEntityFieldAccessCheck implements QuickEditEntityFieldAccessCheckInterface {

  /**
   * {@inheritdoc}
   */
  public function accessEditEntityField(EntityInterface $entity, $field_name) {
    switch (\Drupal::state()
      ->get('quickedit_test_field_access')) {
      case 'allowed':
        return AccessResult::allowed();
      case 'neutral':
        return AccessResult::neutral();
      case 'forbidden':
        return AccessResult::forbidden();
      default:
        throw new \OutOfRangeException("The state for the 'quickedit_test_field_access' key must be either 'allowed', 'neutral' or 'forbidden'.");
    }
  }

}

Members