You are here

function CourseObject::set in Course 3.x

Same name and namespace in other branches
  1. 8.3 src/Entity/CourseObject.php \Drupal\course\Entity\CourseObject::set()
  2. 8.2 src/Entity/CourseObject.php \Drupal\course\Entity\CourseObject::set()

Set field in extra data if needed.

Overrides ContentEntityBase::set

2 calls to CourseObject::set()
CourseObject::save in src/Entity/CourseObject.php
Apply configuration from session and let objects create their instances before saving the course object.
CourseObjectAttendance::preSave in modules/course_attendance/src/Plugin/course/CourseObject/CourseObjectAttendance.php
Generate an attendance code if not provided.

File

src/Entity/CourseObject.php, line 1018

Class

CourseObject
Parent abstract base class of all course objects.

Namespace

Drupal\course\Entity

Code

function set($name, $value, $notify = TRUE) {
  if (!in_array($name, array_keys($this
    ->getFieldDefinitions()))) {
    $extra = parent::get('data')
      ->getValue() ?? [];
    $extra[0][$name] = $value;
    return parent::set('data', $extra[0]);
  }
  else {
    return parent::set($name, $value, $notify);
  }
}