|
|
- <?php
-
- namespace Drupal\sample_migration\Plugin\migrate\source;
-
- use Drupal\migrate\Plugin\migrate\source\SqlBase;
- use Drupal\migrate\Row;
-
- /**
- * Provides a 'Random Database' migrate source.
- *
- * @MigrateSource(
- * id = "RandomDatabases"
- * )
- */
- class RandomDatabases extends SqlBase {
-
- /**
- * {@inheritdoc}
- */
- public function query() {
- $query = $this->select('Content', 'c');
- $query->fields('c', [
- 'ID',
- 'Title',
- 'Body',
- ]);
- return $query;
- }
-
- /**
- * {@inheritdoc}
- */
- public function fields() {
- $fields = [
- 'ID' => $this->t('Source ID'),
- 'Title' => $this->t('Title'),
- 'Body' => $this->t('Body'),
- ];
- return $fields;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getIds() {
- return [
- 'ID' => [
- 'type' => 'integer',
- 'alias'=> 'ID'
- ]
- ];
- }
-
- }
|