You are here

function CourseObjectNode::preSave in Course 8.3

Same name and namespace in other branches
  1. 8.2 modules/course_content/src/Course/Object/CourseObjectNode.php \Drupal\course_content\Course\Object\CourseObjectNode::preSave()
  2. 3.x modules/course_content/src/Course/Object/CourseObjectNode.php \Drupal\course_content\Course\Object\CourseObjectNode::preSave()

Clone a node before saving.

Overrides ContentEntityBase::preSave

File

modules/course_content/src/Course/Object/CourseObjectNode.php, line 304

Class

CourseObjectNode
A course object that uses a node as a base.

Namespace

Drupal\course_content\Course\Object

Code

function preSave(Drupal\Core\Entity\EntityStorageInterface $storage, $update = TRUE) {
  if ($this
    ->getOption('clone_and_reference')) {
    module_load_include('inc', 'clone', 'clone.pages');
    $new_nid = clone_node_save($this
      ->getOption('instance'));
    $this
      ->setInstanceId($new_nid);
    $this
      ->setOption('clone_and_reference', 0);
  }
  parent::preSave($storage, $update);
}