From e128c1a40fe6fbe975588e6754e5a7c40baa4927 Mon Sep 17 00:00:00 2001
From: grayside <grayside@346868.no-reply.drupal.org>
Date: Tue, 11 Oct 2016 16:10:37 -0500
Subject: [PATCH] Issue #2780965 by Grayside: Add support for original data
 values with JSON data_parser plugin

---
 .../install/migrate_plus.migration.wine_role_json.yml      | 7 +++++++
 src/Plugin/migrate_plus/data_parser/Json.php               | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/migrate_example_advanced/config/install/migrate_plus.migration.wine_role_json.yml b/migrate_example_advanced/config/install/migrate_plus.migration.wine_role_json.yml
index 0782e111..e8991a69 100755
--- a/migrate_example_advanced/config/install/migrate_plus.migration.wine_role_json.yml
+++ b/migrate_example_advanced/config/install/migrate_plus.migration.wine_role_json.yml
@@ -7,6 +7,13 @@ source:
   plugin: url
   data_fetcher_plugin: http
   data_parser_plugin: json
+  # The data_parser normally limits the fields passed on to the source plugin
+  # to fields configured to be used as part of the migration. To support more
+  # dynamic migrations, the JSON data parser supports including the original
+  # data for the current row. Simply include the 'include_raw_data' flag set
+  # to `true` to enable this. This option is disabled by default to minimize
+  # memory footprint for migrations that do not need this capability.
+  # include_raw_data: true
   # Normally, this is one or more fully-qualified URLs or file paths. Because
   # we can't hardcode your local URL, we provide a relative path here which
   # hook_install() will rewrite to a full URL for the current site.
diff --git a/src/Plugin/migrate_plus/data_parser/Json.php b/src/Plugin/migrate_plus/data_parser/Json.php
index ab1a91f7..7fdc3873 100755
--- a/src/Plugin/migrate_plus/data_parser/Json.php
+++ b/src/Plugin/migrate_plus/data_parser/Json.php
@@ -116,6 +116,9 @@ class Json extends DataParserPluginBase implements ContainerFactoryPluginInterfa
         }
         $this->currentItem[$field_name] = $field_data;
       }
+      if (!empty($this->configuration['include_raw_data'])) {
+        $this->currentItem['raw'] = $current;
+      }
       $this->iterator->next();
     }
   }
-- 
GitLab