Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / migrate_plus / migrate_example / src / Plugin / migrate / source / BeerComment.php
1 <?php
2
3 namespace Drupal\migrate_example\Plugin\migrate\source;
4
5 use Drupal\migrate\Plugin\migrate\source\SqlBase;
6
7 /**
8  * Source plugin for beer comments.
9  *
10  * @MigrateSource(
11  *   id = "beer_comment"
12  * )
13  */
14 class BeerComment extends SqlBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function query() {
20     $query = $this->select('migrate_example_beer_comment', 'mec')
21                  ->fields('mec', ['cid', 'cid_parent', 'name', 'mail', 'aid',
22                    'body', 'bid', 'subject'])
23                  ->orderBy('cid_parent', 'ASC');
24     return $query;
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function fields() {
31     $fields = [
32       'cid' => $this->t('Comment ID'),
33       'cid_parent' => $this->t('Parent comment ID in case of comment replies'),
34       'name' => $this->t('Comment name (if anon)'),
35       'mail' => $this->t('Comment email (if anon)'),
36       'aid' => $this->t('Account ID (if any)'),
37       'bid' => $this->t('Beer ID that is being commented upon'),
38       'subject' => $this->t('Comment subject'),
39     ];
40
41     return $fields;
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function getIds() {
48     return [
49       'cid' => [
50         'type' => 'integer',
51         'alias' => 'mec',
52       ],
53     ];
54   }
55
56 }