You are here

function social_event_get_current_event in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/social_event.module \social_event_get_current_event()
  2. 8.7 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|\Drupal\node\Entity\Node|null The event or NULL if nothing found.

1 call to social_event_get_current_event()
SocialEventManagersViewsBulkOperationsBulkForm::viewsForm in modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php

File

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

Code

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