Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / migrate_plus / migrate_example / src / Plugin / migrate / source / BeerUser.php
index b0d963d3fd00946b03390bae7c185dcbbb576235..398f87c6963fcfe8220b7cd2e09d24aa73c823e4 100644 (file)
@@ -18,9 +18,19 @@ class BeerUser extends SqlBase {
    * {@inheritdoc}
    */
   public function query() {
+    $fields = [
+      'aid',
+      'status',
+      'registered',
+      'username',
+      'nickname',
+      'password',
+      'email',
+      'sex',
+      'beers',
+    ];
     return $this->select('migrate_example_beer_account', 'mea')
-      ->fields('mea', ['aid', 'status', 'registered', 'username', 'nickname',
-                            'password', 'email', 'sex', 'beers']);
+      ->fields('mea', $fields);
   }
 
   /**
@@ -58,27 +68,22 @@ class BeerUser extends SqlBase {
    * {@inheritdoc}
    */
   public function prepareRow(Row $row) {
-    /**
-     * prepareRow() is the most common place to perform custom run-time
-     * processing that isn't handled by an existing process plugin. It is called
-     * when the raw data has been pulled from the source, and provides the
-     * opportunity to modify or add to that data, creating the canonical set of
-     * source data that will be fed into the processing pipeline.
-     *
-     * In our particular case, the list of a user's favorite beers is a pipe-
-     * separated list of beer IDs. The processing pipeline deals with arrays
-     * representing multi-value fields naturally, so we want to explode that
-     * string to an array of individual beer IDs.
-     */
+    // A prepareRow() is the most common place to perform custom run-time
+    // processing that isn't handled by an existing process plugin. It is called
+    // when the raw data has been pulled from the source, and provides the
+    // opportunity to modify or add to that data, creating the canonical set of
+    // source data that will be fed into the processing pipeline.
+    // In our particular case, the list of a user's favorite beers is a pipe-
+    // separated list of beer IDs. The processing pipeline deals with arrays
+    // representing multi-value fields naturally, so we want to explode that
+    // string to an array of individual beer IDs.
     if ($value = $row->getSourceProperty('beers')) {
       $row->setSourceProperty('beers', explode('|', $value));
     }
-    /**
-     * Always call your parent! Essential processing is performed in the base
-     * class. Be mindful that prepareRow() returns a boolean status - if FALSE
-     * that indicates that the item being processed should be skipped. Unless
-     * we're deciding to skip an item ourselves, let the parent class decide.
-     */
+    // Always call your parent! Essential processing is performed in the base
+    // class. Be mindful that prepareRow() returns a boolean status - if FALSE
+    // that indicates that the item being processed should be skipped. Unless
+    // we're deciding to skip an item ourselves, let the parent class decide.
     return parent::prepareRow($row);
   }