You are here

gevent.module in Event 8

Enables Group functionality for the Event module.

File

modules/gevent/gevent.module
View source
<?php

/**
 * @file
 * Enables Group functionality for the Event module.
 */
use Drupal\event\Entity\EventTypeInterface;
use Drupal\Core\Url;

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function gevent_event_type_insert(EventTypeInterface $event_type) {
  \Drupal::service('plugin.manager.group_content_enabler')
    ->clearCachedDefinitions();
}

/**
 * Implements hook_entity_operation().
 */
function gevent_entity_operation($entity) {
  $operations = [];
  if ($entity
    ->getEntityTypeId() == 'group' && \Drupal::moduleHandler()
    ->moduleExists('views')) {
    if ($entity
      ->hasPermission('access group_event overview', \Drupal::currentUser())) {

      /** @var \Symfony\Component\Routing\RouterInterface $router */
      $router = \Drupal::service('router.no_access_checks');
      if ($router
        ->getRouteCollection()
        ->get('view.group_events.page_1') !== NULL) {
        $operations['events'] = [
          'title' => t('Events'),
          'weight' => 20,
          'url' => Url::fromRoute('view.group_events.page_1', [
            'group' => $entity
              ->id(),
          ]),
        ];
      }
    }
  }
  return $operations;
}