function MockQuickEditEntityFieldAccessCheck::accessEditEntityField
Same name and namespace in other branches
- 8.9.x core/modules/quickedit/tests/modules/src/MockQuickEditEntityFieldAccessCheck.php \Drupal\quickedit_test\MockQuickEditEntityFieldAccessCheck::accessEditEntityField()
Checks access to edit the requested field of the requested entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity.
string $field_name: The field name.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
Overrides QuickEditEntityFieldAccessCheckInterface::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_testCode
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'.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.