X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FCommands%2Fgenerate%2FGenerators%2FMigrate%2Fmigration.twig;fp=vendor%2Fdrush%2Fdrush%2Fsrc%2FCommands%2Fgenerate%2FGenerators%2FMigrate%2Fmigration.twig;h=0fb1be413c46353c6da13d76c6d544515a47a5d6;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/drush/drush/src/Commands/generate/Generators/Migrate/migration.twig b/vendor/drush/drush/src/Commands/generate/Generators/Migrate/migration.twig new file mode 100644 index 000000000..0fb1be413 --- /dev/null +++ b/vendor/drush/drush/src/Commands/generate/Generators/Migrate/migration.twig @@ -0,0 +1,98 @@ +select('migrate_example_beer_node', 'b') + ->fields('b', ['bid', 'name', 'body', 'excerpt', 'aid', + 'countries', 'image', 'image_alt', 'image_title', + 'image_description']); + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + $fields = [ + 'bid' => $this->t('Beer ID'), + 'name' => $this->t('Name of beer'), + 'body' => $this->t('Full description of the beer'), + 'excerpt' => $this->t('Abstract for this beer'), + 'aid' => $this->t('Account ID of the author'), + 'countries' => $this->t('Countries of origin. Multiple values, delimited by pipe'), + 'image' => $this->t('Image path'), + 'image_alt' => $this->t('Image ALT'), + 'image_title' => $this->t('Image title'), + 'image_description' => $this->t('Image description'), + // Note that this field is not part of the query above - it is populated + // by prepareRow() below. You should document all source properties that + // are available for mapping after prepareRow() is called. + 'terms' => $this->t('Applicable styles'), + ]; + + return $fields; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + return [ + 'bid' => [ + 'type' => 'integer', + 'alias' => 'b', + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row) { + /** + * As explained above, we need to pull the style relationships into our + * source row here, as an array of 'style' values (the unique ID for + * the beer_term migration). + */ + $terms = $this->select('migrate_example_beer_topic_node', 'bt') + ->fields('bt', ['style']) + ->condition('bid', $row->getSourceProperty('bid')) + ->execute() + ->fetchCol(); + $row->setSourceProperty('terms', $terms); + + // As we did for favorite beers in the user migration, we need to explode + // the multi-value country names. + if ($value = $row->getSourceProperty('countries')) { + $row->setSourceProperty('countries', explode('|', $value)); + } + return parent::prepareRow($row); + } + +}