CourseType.php in Course 3.x
File
modules/course_migrate/src/Plugin/migrate/source/CourseType.php
View source
<?php
namespace Drupal\course_migrate\Plugin\migrate\source;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
class CourseType extends DrupalSqlBase {
public function query() {
$course_types = [];
$query = $this
->select('node_type', 'nt')
->fields('nt', [
'type',
'name',
]);
$result = $query
->execute();
while ($row = $result
->fetch()) {
if ($this
->variableGet("course_use_" . $row['type'], 0) == 1) {
$course_types[] = $row['type'];
}
}
$query = $this
->select('node_type', 'nt')
->fields('nt', [
'type',
'name',
]);
$query
->condition('type', $course_types, 'in');
return $query;
}
public function fields() {
return [
'type' => $this
->t('The machine-readable name of this profile type.'),
'name' => $this
->t('The human-readable name of this profile type.'),
];
}
public function getIds() {
$ids['type']['type'] = 'string';
return $ids;
}
}