You are here

public function QuickNodeCloneNodeAccess::cloneNode in Quick Node Clone 8

Limit access to the clone according to their restricted state.

Parameters

\Drupal\Core\Session\AccountInterface $account: The account object.

int $node: The node id.

Return value

\Drupal\Core\Access\AccessResultAllowed|\Drupal\Core\Access\AccessResultForbidden If allowed, AccessResultAllowed isAllowed() will be TRUE. If forbidden, isForbidden() will be TRUE.

1 string reference to 'QuickNodeCloneNodeAccess::cloneNode'
quick_node_clone.routing.yml in ./quick_node_clone.routing.yml
quick_node_clone.routing.yml

File

src/Controller/QuickNodeCloneNodeAccess.php, line 26

Class

QuickNodeCloneNodeAccess
Access control for cloning nodes.

Namespace

Drupal\quick_node_clone\Controller

Code

public function cloneNode(AccountInterface $account, $node) {
  $node = Node::load($node);
  if (_quick_node_clone_has_clone_permission($node)) {
    $result = AccessResult::allowed();
  }
  else {
    $result = AccessResult::forbidden();
  }
  $result
    ->addCacheableDependency($node);
  return $result;
}