Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / migrate_plus / migrate_example / src / Plugin / migrate / source / BeerNode.php
index 8d9f0bbfdc5580f95b588ac8fcc8f4453235523c..40ac4df29d36bca6950880ce39437fce0891ad1a 100644 (file)
@@ -18,21 +18,29 @@ class BeerNode extends SqlBase {
    * {@inheritdoc}
    */
   public function query() {
-    /**
-     * An important point to note is that your query *must* return a single row
-     * for each item to be imported. Here we might be tempted to add a join to
-     * migrate_example_beer_topic_node in our query, to pull in the
-     * relationships to our categories. Doing this would cause the query to
-     * return multiple rows for a given node, once per related value, thus
-     * processing the same node multiple times, each time with only one of the
-     * multiple values that should be imported. To avoid that, we simply query
-     * the base node data here, and pull in the relationships in prepareRow()
-     * below.
-     */
+    // An important point to note is that your query *must* return a single row
+    // for each item to be imported. Here we might be tempted to add a join to
+    // migrate_example_beer_topic_node in our query, to pull in the
+    // relationships to our categories. Doing this would cause the query to
+    // return multiple rows for a given node, once per related value, thus
+    // processing the same node multiple times, each time with only one of the
+    // multiple values that should be imported. To avoid that, we simply query
+    // the base node data here, and pull in the relationships in prepareRow()
+    // below.
+    $fields = [
+      'bid',
+      'name',
+      'body',
+      'excerpt',
+      'aid',
+      'countries',
+      'image',
+      'image_alt',
+      'image_title',
+      'image_description',
+    ];
     $query = $this->select('migrate_example_beer_node', 'b')
-                 ->fields('b', ['bid', 'name', 'body', 'excerpt', 'aid',
-                   'countries', 'image', 'image_alt', 'image_title',
-                   'image_description']);
+      ->fields('b', $fields);
     return $query;
   }
 
@@ -76,13 +84,11 @@ class BeerNode extends SqlBase {
    * {@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).
-     */
+    // 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'])
+      ->fields('bt', ['style'])
       ->condition('bid', $row->getSourceProperty('bid'))
       ->execute()
       ->fetchCol();