public function NodeAccessController::access

Checks access to an operation on a given entity or entity translation.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check access.

string $operation: The operation access should be checked for. Usually one of "view", "create", "update" or "delete".

string $langcode: (optional) The language code for which to check access. Defaults to Language::LANGCODE_DEFAULT.

\Drupal\Core\Session\AccountInterface $account: (optional) The user session for which to check access, or NULL to check access for the current user. Defaults to NULL.

Return value

bool TRUE if access was granted, FALSE otherwise.

Overrides EntityAccessController::access

File

drupal/core/modules/node/lib/Drupal/node/NodeAccessController.php, line 24
Contains \Drupal\node\NodeAccessController.

Class

NodeAccessController
Defines the access controller for the node entity type.

Namespace

Drupal\node

Code

public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) {
  if (user_access('bypass node access', $account)) {
    return TRUE;
  }
  if (!user_access('access content', $account)) {
    return FALSE;
  }
  return parent::access($entity, $operation, $langcode, $account);
}