87ae972140fd73a2203bcd184f8a97c708c99fe2
[yaffs-website] / web / core / modules / book / src / Plugin / migrate / source / d6 / Book.php
1 <?php
2
3 namespace Drupal\book\Plugin\migrate\source\d6;
4
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6
7 /**
8  * Drupal 6 book source.
9  *
10  * @MigrateSource(
11  *   id = "d6_book",
12  *   source_module = "book"
13  * )
14  */
15 class Book extends DrupalSqlBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function query() {
21     $query = $this->select('book', 'b')->fields('b', ['nid', 'bid']);
22     $query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
23     $ml_fields = ['mlid', 'plid', 'weight', 'has_children', 'depth'];
24     for ($i = 1; $i <= 9; $i++) {
25       $field = "p$i";
26       $ml_fields[] = $field;
27       $query->orderBy('ml.' . $field);
28     }
29     $query->fields('ml', $ml_fields);
30     return $query;
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function getIds() {
37     $ids['mlid']['type'] = 'integer';
38     $ids['mlid']['alias'] = 'ml';
39     return $ids;
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   public function fields() {
46     return [
47       'nid' => $this->t('Node ID'),
48       'bid' => $this->t('Book ID'),
49       'mlid' => $this->t('Menu link ID'),
50       'plid' => $this->t('Parent link ID'),
51       'weight' => $this->t('Weight'),
52       'p1' => $this->t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
53       'p2' => $this->t('The second mlid in the materialized path. See p1.'),
54       'p3' => $this->t('The third mlid in the materialized path. See p1.'),
55       'p4' => $this->t('The fourth mlid in the materialized path. See p1.'),
56       'p5' => $this->t('The fifth mlid in the materialized path. See p1.'),
57       'p6' => $this->t('The sixth mlid in the materialized path. See p1.'),
58       'p7' => $this->t('The seventh mlid in the materialized path. See p1.'),
59       'p8' => $this->t('The eighth mlid in the materialized path. See p1.'),
60       'p9' => $this->t('The ninth mlid in the materialized path. See p1.'),
61     ];
62   }
63
64 }