You are here

class ContentAccessNodePageAccessCheck in Content Access 8

Class ContentAccessNodePageAccessCheck.

Determines access to routes based on permissions defined via $module.permissions.yml files.

Hierarchy

Expanded class hierarchy of ContentAccessNodePageAccessCheck

1 string reference to 'ContentAccessNodePageAccessCheck'
content_access.services.yml in ./content_access.services.yml
content_access.services.yml
1 service uses ContentAccessNodePageAccessCheck
access_check.content_access_node_page_access in ./content_access.services.yml
Drupal\content_access\Access\ContentAccessNodePageAccessCheck

File

src/Access/ContentAccessNodePageAccessCheck.php, line 16

Namespace

Drupal\content_access\Access
View source
class ContentAccessNodePageAccessCheck implements AccessInterface {

  /**
   * {@inheritdoc}
   */
  public function access(AccountInterface $account, RouteMatchInterface $route_match) {
    $node = $route_match
      ->getParameter('node');
    $all_nodes_access = $account
      ->hasPermission('grant content access');
    $own_node_access = $account
      ->hasPermission('grant own content access') && $account
      ->id() == $node
      ->getOwnerId();
    return AccessResult::allowedIf(content_access_get_settings('per_node', $node
      ->getType()) && ($all_nodes_access || $own_node_access));
  }

}

Members