You are here

function CourseObjectAttendance::preSave in Course 3.x

Generate an attendance code if not provided.

Overrides ContentEntityBase::preSave

File

modules/course_attendance/src/Plugin/course/CourseObject/CourseObjectAttendance.php, line 132

Class

CourseObjectAttendance
Plugin annotation @CourseObject( id = "attendance", label = "Attendance", )

Namespace

Drupal\course_attendance\Plugin\course\CourseObject

Code

function preSave(EntityStorageInterface $storage) {
  if ($this
    ->get('instance')
    ->isEmpty()) {
    $this
      ->set('instance', self::generateWord());
  }
}