You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
871 B

  1. <?php
  2. namespace Drupal\sample_migration\Plugin\migrate\source;
  3. use Drupal\migrate\Plugin\migrate\source\SqlBase;
  4. use Drupal\migrate\Row;
  5. /**
  6. * Provides a 'Random Database' migrate source.
  7. *
  8. * @MigrateSource(
  9. * id = "RandomDatabases"
  10. * )
  11. */
  12. class RandomDatabases extends SqlBase {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function query() {
  17. $query = $this->select('Content', 'c');
  18. $query->fields('c', [
  19. 'ID',
  20. 'Title',
  21. 'Body',
  22. ]);
  23. return $query;
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function fields() {
  29. $fields = [
  30. 'ID' => $this->t('Source ID'),
  31. 'Title' => $this->t('Title'),
  32. 'Body' => $this->t('Body'),
  33. ];
  34. return $fields;
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function getIds() {
  40. return [
  41. 'ID' => [
  42. 'type' => 'integer',
  43. 'alias'=> 'ID'
  44. ]
  45. ];
  46. }
  47. }