You are here

function social_event_get_current_event in Open Social 8.9

Same name and namespace in other branches
  1. 8.7 modules/social_features/social_event/social_event.module \social_event_get_current_event()
  2. 8.8 modules/social_features/social_event/social_event.module \social_event_get_current_event()
  3. 10.3.x modules/social_features/social_event/social_event.module \social_event_get_current_event()
  4. 10.0.x modules/social_features/social_event/social_event.module \social_event_get_current_event()
  5. 10.1.x modules/social_features/social_event/social_event.module \social_event_get_current_event()
  6. 10.2.x modules/social_features/social_event/social_event.module \social_event_get_current_event()

Return the Event from a given page.

Return value

\Drupal\Core\Entity\EntityInterface|null The event or NULL if nothing found.

5 calls to social_event_get_current_event()
EnrollRequestsOverviewSubscriber::checkAccessToEnrollRequestsOverview in modules/social_features/social_event/src/Routing/EnrollRequestsOverviewSubscriber.php
Check if the user is allowed to view this overview.
EventRequestEnrollmentNotification::__construct in modules/social_features/social_event/src/Plugin/Block/EventRequestEnrollmentNotification.php
Constructs SocialGroupRequestMembershipNotification.
SocialEventManagersViewsBulkOperationsBulkForm::viewsForm in modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php
social_event_manager_or_organizer in modules/social_features/social_event/social_event.module
Check if the user is allowed to manage Enrollments.
social_event_preprocess_page in modules/social_features/social_event/social_event.module
Implements hook_preprocess_page().

File

modules/social_features/social_event/social_event.module, line 825
The Social event module.

Code

function social_event_get_current_event() {
  $event =& drupal_static(__FUNCTION__);
  if (!isset($event)) {
    $node = \Drupal::service('current_route_match')
      ->getParameter('node');
    if ($node !== NULL && !$node instanceof NodeInterface) {
      $node = Node::load($node);
    }
    if ($node instanceof NodeInterface && $node
      ->getType() === 'event') {
      $event = $node;
    }

    // If we don't have an event then we can go back to NULL.
    if (!isset($event)) {
      $event = NULL;
    }
  }
  return $event;
}