You are here

activity_basics.api.php in Open Social 8.8

Hooks provided by the Activity module.

File

modules/custom/activity_basics/activity_basics.api.php
View source
<?php

/**
 * @file
 * Hooks provided by the Activity module.
 */

/**
 * @addtogroup hooks
 * @{
 */

/**
 * Provide a method to alter the recipients used as Organizers.
 *
 * @param array $recipients
 *   The recipients receiving a notification.
 * @param \Drupal\node\Entity\Node $event
 *   The Event that was joined.
 * @param array $data
 *   The data concerning the activity needed for context.
 *
 * @ingroup activity_basics_api
 */
function hook_activity_recipient_organizer_alter(array &$recipients, \Drupal\node\Entity\Node $event, array $data) {
  $organizers = $event
    ->getOwnerId();
  if ($data['target_type'] !== 'event_enrollment') {
    return;
  }

  // Add the creator of the Event as a recipient.
  $recipients[] = [
    'target_type' => 'user',
    'target_id' => $organizers
      ->getOwnerId(),
  ];
}

/**
 * @} End of "addtogroup hooks".
 */

Functions

Namesort descending Description
hook_activity_recipient_organizer_alter Provide a method to alter the recipients used as Organizers.