You are here

public function EventRequestEnrollmentNotification::access in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/src/Plugin/Block/EventRequestEnrollmentNotification.php \Drupal\social_event\Plugin\Block\EventRequestEnrollmentNotification::access()
  2. 10.3.x modules/social_features/social_event/src/Plugin/Block/EventRequestEnrollmentNotification.php \Drupal\social_event\Plugin\Block\EventRequestEnrollmentNotification::access()
  3. 10.1.x modules/social_features/social_event/src/Plugin/Block/EventRequestEnrollmentNotification.php \Drupal\social_event\Plugin\Block\EventRequestEnrollmentNotification::access()
  4. 10.2.x modules/social_features/social_event/src/Plugin/Block/EventRequestEnrollmentNotification.php \Drupal\social_event\Plugin\Block\EventRequestEnrollmentNotification::access()

Overrides BlockPluginTrait::access

File

modules/social_features/social_event/src/Plugin/Block/EventRequestEnrollmentNotification.php, line 175

Class

EventRequestEnrollmentNotification
Provides a 'Event requests notification' block.

Namespace

Drupal\social_event\Plugin\Block

Code

public function access(AccountInterface $account, $return_as_object = FALSE) {
  $is_event_page = isset($this->event);

  // Show this block only on these specific routes.
  // We can't use the Block UI as you can't specify just the node canonical
  // route.
  $routes = [
    'entity.node.canonical',
    'view.event_enrollments.view_enrollments',
    'view.event_manage_enrollments.page_manage_enrollments',
    'view.event_manage_enrollment_invites.page_manage_enrollment_invites',
    'view.manage_enrollments.page',
    'view.managers.view_managers',
    'social_event_managers.add_enrollees',
    'social_event_managers.vbo.execute_configurable',
    'social_event_managers.vbo.confirm',
  ];

  // We have an event and it's part of the above list of routes.
  if ($this->event instanceof NodeInterface && in_array($this->routeMatch
    ->getRouteName(), $routes, TRUE)) {
    return AccessResult::allowedIf($is_event_page && social_event_manager_or_organizer($this->event));
  }
  return AccessResult::forbidden();
}