class EnrollRequestsOverviewSubscriber in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/src/Routing/EnrollRequestsOverviewSubscriber.php \Drupal\social_event\Routing\EnrollRequestsOverviewSubscriber
- 10.3.x modules/social_features/social_event/src/Routing/EnrollRequestsOverviewSubscriber.php \Drupal\social_event\Routing\EnrollRequestsOverviewSubscriber
- 10.1.x modules/social_features/social_event/src/Routing/EnrollRequestsOverviewSubscriber.php \Drupal\social_event\Routing\EnrollRequestsOverviewSubscriber
- 10.2.x modules/social_features/social_event/src/Routing/EnrollRequestsOverviewSubscriber.php \Drupal\social_event\Routing\EnrollRequestsOverviewSubscriber
Class RedirectSubscriber.
@package Drupal\social_event\Routing
Hierarchy
- class \Drupal\social_event\Routing\EnrollRequestsOverviewSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of EnrollRequestsOverviewSubscriber
1 string reference to 'EnrollRequestsOverviewSubscriber'
- social_event.services.yml in modules/
social_features/ social_event/ social_event.services.yml - modules/social_features/social_event/social_event.services.yml
1 service uses EnrollRequestsOverviewSubscriber
- social_event.enroll_request_overview_subscriber in modules/
social_features/ social_event/ social_event.services.yml - Drupal\social_event\Routing\EnrollRequestsOverviewSubscriber
File
- modules/
social_features/ social_event/ src/ Routing/ EnrollRequestsOverviewSubscriber.php, line 17
Namespace
Drupal\social_event\RoutingView source
class EnrollRequestsOverviewSubscriber implements EventSubscriberInterface {
/**
* Get the request events.
*
* @inheritDoc
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = [
'checkAccessToEnrollRequestsOverview',
];
return $events;
}
/**
* Check if the user is allowed to view this overview.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The event.
*/
public function checkAccessToEnrollRequestsOverview(GetResponseEvent $event) {
$current_route = \Drupal::routeMatch()
->getRouteName();
// First, lets check if the route matches.
if ($current_route === 'view.event_manage_enrollment_requests.page_manage_enrollment_requests') {
// Now lets get some stuff we need to perform some checks on.
$current_event = social_event_get_current_event();
if (!$current_event instanceof NodeInterface) {
return;
}
// Now, lets check:
// - If the current user has a permission to see the overview.
// - If the current user is the owner/creator of this event.
// - If the current user is an organiser/manager of this event.
// And then allow access.
if (social_event_manager_or_organizer()) {
return;
}
// We deny the rest and send them to the front page.
$event
->setResponse(new RedirectResponse(Url::fromRoute('entity.node.canonical', [
'node' => $current_event
->id(),
])
->toString()));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EnrollRequestsOverviewSubscriber:: |
public | function | Check if the user is allowed to view this overview. | |
EnrollRequestsOverviewSubscriber:: |
public static | function | Get the request events. |