You are here

public function ReferencePreviewAccessCheck::access in Bibliography & Citation 2.0.x

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

Checks access to the reference preview page.

Parameters

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

\Drupal\bibcite_entity\Entity\ReferenceInterface $bibcite_reference_preview: The reference that is being previewed.

Return value

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

File

modules/bibcite_entity/src/Access/ReferencePreviewAccessCheck.php, line 45

Class

ReferencePreviewAccessCheck
Determines access to reference previews.

Namespace

Drupal\bibcite_entity\Access

Code

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

  // If checking whether a reference of a particular type may be created.
  if ($bibcite_reference_preview
    ->isNew()) {
    return $access_control_handler
      ->createAccess($bibcite_reference_preview
      ->bundle(), $account, [], TRUE);
  }
  else {
    return $bibcite_reference_preview
      ->access('update', $account, TRUE);
  }
}