Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / migrate_plus / migrate_example_advanced / src / Plugin / migrate / source / WineTerm.php
1 <?php
2
3 namespace Drupal\migrate_example_advanced\Plugin\migrate\source;
4
5 use Drupal\migrate\Plugin\migrate\source\SqlBase;
6
7 /**
8  * A SQL-based source plugin, to retrieve category data from a source database.
9  *
10  * @MigrateSource(
11  *   id = "wine_term"
12  * )
13  */
14 class WineTerm extends SqlBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function query() {
20     $fields = [
21       'categoryid',
22       'type',
23       'name',
24       'details',
25       'category_parent',
26       'ordering',
27     ];
28     return $this->select('migrate_example_advanced_categories', 'wc')
29       ->fields('wc', $fields)
30       // This sort assures that parents are saved before children.
31       ->orderBy('category_parent', 'ASC');
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   public function fields() {
38     $fields = [
39       'categoryid' => $this->t('Unique ID of the category'),
40       'type' => $this->t('Category type corresponding to Drupal vocabularies'),
41       'name' => $this->t('Category name'),
42       'details' => $this->t('Description of the category'),
43       'category_parent' => $this->t('ID of the parent category'),
44       'ordering' => $this->t('Order in which to display this category'),
45     ];
46
47     return $fields;
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function getIds() {
54     return ['categoryid' => ['type' => 'integer']];
55   }
56
57 }