You are here

public function MockQuickEditEntityFieldAccessCheck::accessEditEntityField in Drupal 10

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

File

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

Class

MockQuickEditEntityFieldAccessCheck
Access check for in-place editing entity fields.

Namespace

Drupal\quickedit_test

Code

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'.");
  }
}