You are here

public static function ViewAccessCheck::check_node_access in Node Accessibility 8

A custom access check.

Parameters

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

int $nid: The node id to perform the access check against. #param int|null $vid (optional) The node revision id to check against. Set to NULL to use the latest node.

Return value

bool TRUE for access granted, FALSE otherwise.

1 call to ViewAccessCheck::check_node_access()
NodeAccessibilityController::revisionOverview in src/Controller/NodeAccessibilityController.php
Generates an overview table of older revisions of a node.

File

src/Access/ViewAccessCheck.php, line 33

Class

ViewAccessCheck
Determines access to for node add pages.

Namespace

Drupal\node_accessibility\Access

Code

public static function check_node_access(AccountInterface $account, $nid, $vid = NULL) {
  if (!$account
    ->hasPermission('perform node accessibility validation')) {
    return FALSE;
  }
  if ($nid == 0) {
    return FALSE;
  }
  $settings = TypeSettingsStorage::loadByNodeAsArray($nid);
  if (is_numeric($vid)) {
    if (!static::nodeRevisionIsValid($nid, (int) $vid)) {
      return FALSE;
    }
  }
  if (empty($settings['node_type'])) {
    return FALSE;
  }
  if (empty($settings['enabled']) || $settings['enabled'] == 'disabled') {
    return FALSE;
  }
  return TRUE;
}