3 namespace Drupal\file\Plugin\migrate\source\d6;
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
9 * Drupal 6 upload source from database.
13 * source_provider = "upload"
16 class Upload extends DrupalSqlBase {
19 * The join options between the node and the upload table.
21 const JOIN = 'n.nid = u.nid AND n.vid = u.vid';
26 public function query() {
27 $query = $this->select('upload', 'u')
29 ->fields('u', ['nid', 'vid']);
30 $query->innerJoin('node', 'n', static::JOIN);
31 $query->addField('n', 'type');
38 public function prepareRow(Row $row) {
39 $query = $this->select('upload', 'u')
40 ->fields('u', ['fid', 'description', 'list'])
41 ->condition('u.nid', $row->getSourceProperty('nid'))
42 ->orderBy('u.weight');
43 $query->innerJoin('node', 'n', static::JOIN);
44 $row->setSourceProperty('upload', $query->execute()->fetchAll());
45 return parent::prepareRow($row);
51 public function fields() {
53 'fid' => $this->t('The file Id.'),
54 'nid' => $this->t('The node Id.'),
55 'vid' => $this->t('The version Id.'),
56 'type' => $this->t('The node type'),
57 'description' => $this->t('The file description.'),
58 'list' => $this->t('Whether the list should be visible on the node page.'),
59 'weight' => $this->t('The file weight.'),
66 public function getIds() {
67 $ids['vid']['type'] = 'integer';
68 $ids['vid']['alias'] = 'u';