You are here

protected function FeedbackMessageAccessControlHandler::checkFieldAccess in Feedback 3.x

Default field access as determined by this access control handler.

Parameters

string $operation: The operation access should be checked for. Usually one of "view" or "edit".

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.

\Drupal\Core\Session\AccountInterface $account: The user session for which to check access.

\Drupal\Core\Field\FieldItemListInterface $items: (optional) The field values for which to check access, or NULL if access is checked for the field definition, without any specific value available. Defaults to NULL.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

Overrides EntityAccessControlHandler::checkFieldAccess

File

src/FeedbackMessageAccessControlHandler.php, line 52

Class

FeedbackMessageAccessControlHandler
Access controller for the Feedback message entity.

Namespace

Drupal\feedback

Code

protected function checkFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {

  // Only users with the administer permission can edit administrative fields.
  $administrative_fields = [
    'path',
    'user_id',
    'status',
    'created',
  ];
  if ($operation == 'edit' && in_array($field_definition
    ->getName(), $administrative_fields, TRUE)) {
    return AccessResult::allowedIfHasPermission($account, 'administer feedback message entities');
  }
  return parent::checkFieldAccess($operation, $field_definition, $account, $items);
}