function social_event_entity_operation_alter in Open Social 8.9
Same name and namespace in other branches
- 10.3.x modules/social_features/social_event/social_event.module \social_event_entity_operation_alter()
- 10.0.x modules/social_features/social_event/social_event.module \social_event_entity_operation_alter()
- 10.1.x modules/social_features/social_event/social_event.module \social_event_entity_operation_alter()
- 10.2.x modules/social_features/social_event/social_event.module \social_event_entity_operation_alter()
Implements hook_entity_operation_alter().
File
- modules/
social_features/ social_event/ social_event.module, line 877 - The Social event module.
Code
function social_event_entity_operation_alter(array &$operations, EntityInterface $entity) {
// Check access first.
if (!social_event_manager_or_organizer()) {
return;
}
// Get the node, so we can pass it as a parameter.
$node = \Drupal::routeMatch()
->getParameter('node');
// Check if the entity type is one of event_enrollment and that we're on the
// correct view. Otherwise it would update all actions across the platform.
if ($entity
->getEntityTypeId() === 'event_enrollment' && \Drupal::routeMatch()
->getRouteName() === 'view.event_manage_enrollment_requests.page_manage_enrollment_requests') {
// Empty the current operations.
$operations = [];
// Add the "Approve" option.
$operations['approve']['title'] = t('Approve');
$operations['approve']['url'] = Url::fromRoute('social_event.update_enrollment_request', [
'node' => $node,
'event_enrollment' => $entity
->id(),
'approve' => 1,
]);
// Add the "Decline" option.
$operations['decline']['title'] = t('Decline');
$operations['decline']['url'] = Url::fromRoute('social_event.enrollment_request_decline_form', [
'node' => $node,
'event_enrollment' => $entity
->id(),
]);
}
}