You are here

public function SupportTicketPreviewAccessCheck::access in Support Ticketing System 8

Checks access to the support_ticket preview page.

Parameters

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

\Drupal\support_ticket\SupportTicketInterface $support_ticket_preview: The support_ticket that is being previewed.

Return value

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

File

modules/support_ticket/src/Access/SupportTicketPreviewAccessCheck.php, line 50
Contains \Drupal\support_ticket\Access\SupportTicketPreviewAccessCheck.

Class

SupportTicketPreviewAccessCheck
Determines access to support_ticket previews.

Namespace

Drupal\support_ticket\Access

Code

public function access(AccountInterface $account, SupportTicketInterface $support_ticket_preview) {
  if ($support_ticket_preview
    ->isNew()) {
    $access_controller = $this->entityManager
      ->getAccessControlHandler('support_ticket');
    return $access_controller
      ->createAccess($support_ticket_preview
      ->bundle(), $account, [], TRUE);
  }
  else {
    return $support_ticket_preview
      ->access('update', $account, TRUE);
  }
}