You are here

CourseObject.php in Course 3.x

File

modules/course_migrate/src/Plugin/migrate/source/CourseObject.php
View source
<?php

namespace Drupal\course_migrate\Plugin\migrate\source;

use Drupal\Core\Database\Query\SelectInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;

/**
 * Drupal 7 course object source from database.
 *
 * @MigrateSource(
 *   id = "d7_course_object",
 *   core = {7},
 *   source_module = "course",
 *   destination_module = "course"
 * )
 */
class CourseObject extends FieldableEntity {

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids = [];
    $ids['coid']['type'] = 'integer';
    return $ids;
  }

  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this
      ->select('course_outline', 'co')
      ->fields('co');

    // Ensure all objects have a course. Nothing we can do about orphans.
    $query
      ->join('node', 'n', 'co.nid = n.nid');
    return $query;
  }
  public function fields() {
    return [
      'coid' => 'Course object ID',
      'nid' => 'Course node ID',
      'module' => 'Object module',
      'title' => 'Object title',
      'object_type' => 'Object type',
      'enabled' => 'Enabled',
      'info' => '???',
      'instance' => 'Instance',
      'required' => 'Required',
      'weight' => 'Weight',
      'hidden' => 'Hidden',
      'duration' => 'Duration',
      'uuid' => 'UUID',
      'data' => 'Object data',
    ];
  }

}

Classes

Namesort descending Description
CourseObject Drupal 7 course object source from database.