/** * * @param array $descriptions */ public function add($descriptions) { $this->objects_imported = 0; $this->objects_skipped = 0; foreach ($descriptions as $description) { $title = $description->title; $content = $description->content; $type = $description->type; if (empty($type)) { $type = CourseDescriptionType::repository()->find_one_by_name('general'); $description->description_type = $type->id; } if (empty($title) || empty($content)) { $this->objects_skipped++; continue; } // $description = $this->find_by_title($title); // if ($description && $this->update_existing_entries == false) { // $this->objects_skipped++; // continue; // } $description->c_id = $this->course->c_id; $description->session_id = $this->course->session_id; $repo = CourseDescription::repository(); $success = $repo->save($description); if ($success) { $this->objects_imported++; } else { $this->objects_skipped++; } } }