You are here

class SupportTicketPreviewAccessCheck in Support Ticketing System 8

Determines access to support_ticket previews.

Hierarchy

Expanded class hierarchy of SupportTicketPreviewAccessCheck

1 string reference to 'SupportTicketPreviewAccessCheck'
support_ticket.services.yml in modules/support_ticket/support_ticket.services.yml
modules/support_ticket/support_ticket.services.yml
1 service uses SupportTicketPreviewAccessCheck
access_check.support_ticket.preview in modules/support_ticket/support_ticket.services.yml
Drupal\support_ticket\Access\SupportTicketPreviewAccessCheck

File

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

Namespace

Drupal\support_ticket\Access
View source
class SupportTicketPreviewAccessCheck implements AccessInterface {

  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  protected $entityManager;

  /**
   * Constructs a EntityCreateAccessCheck object.
   *
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The entity manager.
   */
  public function __construct(EntityManagerInterface $entity_manager) {
    $this->entityManager = $entity_manager;
  }

  /**
   * Checks access to the support_ticket preview page.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   * @param \Drupal\support_ticket\SupportTicketInterface $support_ticket_preview
   *   The support_ticket that is being previewed.
   *
   * @return string
   *   A \Drupal\Core\Access\AccessInterface constant value.
   */
  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);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SupportTicketPreviewAccessCheck::$entityManager protected property The entity manager.
SupportTicketPreviewAccessCheck::access public function Checks access to the support_ticket preview page.
SupportTicketPreviewAccessCheck::__construct public function Constructs a EntityCreateAccessCheck object.