You are here

public function ReferenceAddAccessCheck::access in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/Access/ReferenceAddAccessCheck.php \Drupal\bibcite_entity\Access\ReferenceAddAccessCheck::access()

Checks access to the reference add page for the reference type.

Parameters

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

\Drupal\bibcite_entity\Entity\ReferenceTypeInterface $bibcite_reference_type: (optional) The reference type.

Return value

string A \Drupal\Core\Access\AccessInterface constant value.

File

modules/bibcite_entity/src/Access/ReferenceAddAccessCheck.php, line 46

Class

ReferenceAddAccessCheck
Determines access to for reference add pages.

Namespace

Drupal\bibcite_entity\Access

Code

public function access(AccountInterface $account, ReferenceTypeInterface $bibcite_reference_type = NULL) {
  $access_control_handler = $this->entityTypeManager
    ->getAccessControlHandler('bibcite_reference');

  // If checking whether a reference of a particular type may be created.
  if ($bibcite_reference_type) {
    return $access_control_handler
      ->createAccess($bibcite_reference_type
      ->id(), $account, [], TRUE);
  }

  // No opinion.
  return AccessResult::neutral();
}