You are here

function social_event_max_enroll_node_presave in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module \social_event_max_enroll_node_presave()
  2. 10.0.x modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module \social_event_max_enroll_node_presave()
  3. 10.1.x modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module \social_event_max_enroll_node_presave()
  4. 10.2.x modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module \social_event_max_enroll_node_presave()

Implements hook_ENTITY_TYPE_presave().

Set the correct value for AN enroll when enroll method is set to request.

File

modules/social_features/social_event/modules/social_event_max_enroll/social_event_max_enroll.module, line 169
The Social Event Max Enroll module.

Code

function social_event_max_enroll_node_presave(EntityInterface $entity) {

  // If the enroll method is invite then max enrollment must be off.
  if ($entity
    ->getType() === 'event' && $entity
    ->get('field_enroll_method')->value === '3') {
    $entity
      ->set('field_event_max_enroll', '0');
  }
}