You are here

class EventManagementAccessCheck in Booking and Availability Management Tools for Drupal 8

Determines access to for event add pages.

Hierarchy

Expanded class hierarchy of EventManagementAccessCheck

1 string reference to 'EventManagementAccessCheck'
bat_fullcalendar.services.yml in modules/bat_fullcalendar/bat_fullcalendar.services.yml
modules/bat_fullcalendar/bat_fullcalendar.services.yml
1 service uses EventManagementAccessCheck
access_check.bat_fullcalendar.event_management_access in modules/bat_fullcalendar/bat_fullcalendar.services.yml
Drupal\bat_fullcalendar\Access\EventManagementAccessCheck

File

modules/bat_fullcalendar/src/Access/EventManagementAccessCheck.php, line 17
Contains \Drupal\bat_fullcalendar\Access\EventManagementAccessCheck.

Namespace

Drupal\bat_fullcalendar\Access
View source
class EventManagementAccessCheck implements AccessInterface {

  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

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

  /**
   * Checks access to the event add page for the event type.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(AccountInterface $account, $entity_id, $event_type, $event_id, $start_date, $end_date) {
    if ($event_id == 0) {
      return bat_event_access(bat_event_create([
        'type' => $event_type,
      ]), 'create', $account);
    }
    else {
      $event = bat_event_load($event_id);
      return bat_event_access($event, 'update', $account);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EventManagementAccessCheck::$entityTypeManager protected property The entity manager.
EventManagementAccessCheck::access public function Checks access to the event add page for the event type.
EventManagementAccessCheck::__construct public function Constructs a EntityCreateAccessCheck object.