From b9d4c3c0a4c6e30bcc315f83a36587a3fedca5d0 Mon Sep 17 00:00:00 2001 From: David Valdez Date: Mon, 30 Sep 2019 14:59:17 -0500 Subject: [PATCH] The default value of "field_publication_date" is now the created date In the issueindex and node story migrations --- .../migrations/upgrade_d7_node_issueindex.yml | 4 ++- .../migrations/upgrade_d7_node_story.yml | 5 +++- .../process/PublicationDateDefault.php | 28 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 web/modules/custom/geo_upgrade/src/Plugin/migrate/process/PublicationDateDefault.php diff --git a/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_issueindex.yml b/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_issueindex.yml index ca2fcad..1c41692 100644 --- a/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_issueindex.yml +++ b/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_issueindex.yml @@ -165,9 +165,11 @@ process: # process: # target_id: tid field_publication_date: + - plugin: publication_date_default + source: field_publication_date + method: process - plugin: sub_process - source: created process: value: plugin: format_date diff --git a/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_story.yml b/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_story.yml index d31cfcb..02f1704 100644 --- a/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_story.yml +++ b/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_story.yml @@ -213,8 +213,11 @@ process: # target_id: tid field_publication_date: - - plugin: sub_process + plugin: publication_date_default source: field_publication_date + method: process + - + plugin: sub_process process: value: plugin: format_date diff --git a/web/modules/custom/geo_upgrade/src/Plugin/migrate/process/PublicationDateDefault.php b/web/modules/custom/geo_upgrade/src/Plugin/migrate/process/PublicationDateDefault.php new file mode 100644 index 0000000..0ef166d --- /dev/null +++ b/web/modules/custom/geo_upgrade/src/Plugin/migrate/process/PublicationDateDefault.php @@ -0,0 +1,28 @@ +getSourceProperty('created'); + if (empty($value)) { + $value = [0 => ['value' => date('Y-m-d\TH:i:s', $created_date)]]; + } + return $value; + } +}