function Book::query

Same name in other branches
  1. 8.9.x core/modules/book/src/Plugin/migrate/source/Book.php \Drupal\book\Plugin\migrate\source\Book::query()
  2. 10 core/modules/book/src/Plugin/migrate/source/Book.php \Drupal\book\Plugin\migrate\source\Book::query()
  3. 11.x core/modules/book/src/Plugin/migrate/source/Book.php \Drupal\book\Plugin\migrate\source\Book::query()

Overrides SqlBase::query

File

core/modules/book/src/Plugin/migrate/source/Book.php, line 25

Class

Book
Drupal 6/7 book source from database.

Namespace

Drupal\book\Plugin\migrate\source

Code

public function query() {
    $query = $this->select('book', 'b')
        ->fields('b', [
        'nid',
        'bid',
    ]);
    $query->join('menu_links', 'ml', '[b].[mlid] = [ml].[mlid]');
    $ml_fields = [
        'mlid',
        'plid',
        'weight',
        'has_children',
        'depth',
    ];
    foreach (range(1, 9) as $i) {
        $field = "p{$i}";
        $ml_fields[] = $field;
        $query->orderBy('ml.' . $field);
    }
    return $query->fields('ml', $ml_fields);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.