You are here

function opigno_ilt_opigno_ilt_insert in Opigno Instructor-led Trainings 3.x

Same name and namespace in other branches
  1. 8 opigno_ilt.module \opigno_ilt_opigno_ilt_insert()

Implements hook_ENTITY_TYPE_insert().

Updates a calendar event related to a instructor-led training.

File

./opigno_ilt.module, line 250
Contains opigno_ilt.module.

Code

function opigno_ilt_opigno_ilt_insert(EntityInterface $entity) {

  // Set instructor-led training reference on a related calendar event.

  /** @var \Drupal\opigno_ilt\ILTInterface $entity */
  $calendar_event = $entity
    ->getCalendarEvent();
  if (isset($calendar_event)) {
    $calendar_event
      ->set('field_ilt', $entity);
    $calendar_event
      ->save();
  }
}