You are here

nodetype_access.module in Nodetype access 8

Same filename and directory in other branches
  1. 7 nodetype_access.module

Node access module file.

File

nodetype_access.module
View source
<?php

/**
 * @file
 *   Node access module file.
 */
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;

/**
 * Implement hook_node_access().
 */
function nodetype_access_node_access(NodeInterface $node, $op, AccountInterface $account) {

  /** @var \Drupal\nodetype_access\NodeTypeAccessService $service */
  $service = \Drupal::service('nodetype_access.service');
  $accessResult = $service
    ->hookNodeAccess($node, $op, $account);
  return $accessResult;
}

/**
 * Implement hook_query_TAG_alter().
 */
function nodetype_access_query_node_access_alter(AlterableInterface $query) {

  /** @var \Drupal\nodetype_access\NodeTypeAccessService $service */
  $service = \Drupal::service('nodetype_access.service');
  $service
    ->hookQueryNodeAccessAlter($query);
}
function nodetype_access_permissions_callback() {

  /** @var \Drupal\nodetype_access\NodeTypeAccessService $service */
  $service = \Drupal::service('nodetype_access.service');
  return $service
    ->permissions();
}