Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
16 / 16 |
| Upload | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
16 / 16 |
| query | |
100.00% |
1 / 1 |
1 | |
100.00% |
6 / 6 |
|||
| prepareRow | |
100.00% |
1 / 1 |
1 | |
100.00% |
7 / 7 |
|||
| fields | |
100.00% |
1 / 1 |
1 | |
100.00% |
0 / 0 |
|||
| getIds | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\file\Plugin\migrate\source\d6\Upload. | |
| */ | |
| namespace Drupal\file\Plugin\migrate\source\d6; | |
| use Drupal\migrate\Row; | |
| use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; | |
| /** | |
| * Drupal 6 upload source from database. | |
| * | |
| * @MigrateSource( | |
| * id = "d6_upload", | |
| * source_provider = "upload" | |
| * ) | |
| */ | |
| class Upload extends DrupalSqlBase { | |
| /** | |
| * The join options between the node and the upload table. | |
| */ | |
| const JOIN = 'n.nid = u.nid AND n.vid = u.vid'; | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function query() { | |
| $query = $this->select('upload', 'u') | |
| ->distinct() | |
| ->fields('u', array('nid', 'vid')); | |
| $query->innerJoin('node', 'n', static::JOIN); | |
| $query->addField('n', 'type'); | |
| return $query; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function prepareRow(Row $row) { | |
| $query = $this->select('upload', 'u') | |
| ->fields('u', array('fid', 'description', 'list')) | |
| ->condition('u.nid', $row->getSourceProperty('nid')) | |
| ->orderBy('u.weight'); | |
| $query->innerJoin('node', 'n', static::JOIN); | |
| $row->setSourceProperty('upload', $query->execute()->fetchAll()); | |
| return parent::prepareRow($row); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function fields() { | |
| return array( | |
| 'fid' => $this->t('The file Id.'), | |
| 'nid' => $this->t('The node Id.'), | |
| 'vid' => $this->t('The version Id.'), | |
| 'type' => $this->t('The node type'), | |
| 'description' => $this->t('The file description.'), | |
| 'list' => $this->t('Whether the list should be visible on the node page.'), | |
| 'weight' => $this->t('The file weight.'), | |
| ); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getIds() { | |
| $ids['vid']['type'] = 'integer'; | |
| $ids['vid']['alias'] = 'u'; | |
| return $ids; | |
| } | |
| } |