public function TestAccess::hasFieldAccess in Field Permissions 8.2
Same name and namespace in other branches
- 8 tests/modules/field_permissions_test/src/Plugin/FieldPermissionType/TestAccess.php \Drupal\field_permissions_test\Plugin\FieldPermissionType\TestAccess::hasFieldAccess()
Determine if access to the field is granted for a given account.
Parameters
string $operation: The operation to check. Either 'view' or 'edit'.
\Drupal\Core\Entity\EntityInterface $entity: The entity the field is attached to.
\Drupal\Core\Session\AccountInterface $account: The user to check access for.
Return value
bool The access result.
Overrides FieldPermissionTypeInterface::hasFieldAccess
File
- tests/
modules/ field_permissions_test/ src/ Plugin/ FieldPermissionType/ TestAccess.php, line 25
Class
- TestAccess
- A test field permission type plugin.
Namespace
Drupal\field_permissions_test\Plugin\FieldPermissionTypeCode
public function hasFieldAccess($operation, EntityInterface $entity, AccountInterface $account) {
if ($operation === 'view') {
return $account
->hasPermission('foo access');
}
return strpos($this->fieldStorage
->getName(), 'test_') === FALSE;
}