From 42d6b6c7579a231871703f3e672562bce1a0aa28 Mon Sep 17 00:00:00 2001 From: David Valdez Date: Mon, 30 Sep 2019 15:24:54 -0500 Subject: [PATCH] Add the "publication date" default value in the blog and gleaning types --- .../geo_upgrade/migrations/upgrade_d7_node_blog.yml | 11 +++++++++++ .../migrations/upgrade_d7_node_gleaning.yml | 11 +++++++++++ .../migrations/upgrade_d7_node_issueindex.yml | 2 +- .../Plugin/migrate/process/PublicationDateDefault.php | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_blog.yml b/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_blog.yml index 7d5ef88..9fe5af0 100644 --- a/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_blog.yml +++ b/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_blog.yml @@ -157,6 +157,17 @@ process: title: title width: width height: height + field_publication_date: + - plugin: publication_date_default + source: field_publication_date + method: process + - plugin: sub_process + process: + value: + plugin: format_date + from_format: 'Y-m-d\TH:i:s' + to_format: 'Y-m-d' + source: value path/alias: source_path path/pathauto: plugin: default_value diff --git a/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_gleaning.yml b/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_gleaning.yml index 458daab..2dea82b 100644 --- a/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_gleaning.yml +++ b/web/modules/custom/geo_upgrade/migrations/upgrade_d7_node_gleaning.yml @@ -98,6 +98,17 @@ process: target_id: fid display: display description: description + field_publication_date: + - plugin: publication_date_default + source: field_publication_date + method: process + - plugin: sub_process + process: + value: + plugin: format_date + from_format: 'Y-m-d\TH:i:s' + to_format: 'Y-m-d' + source: value path/alias: source_path path/pathauto: plugin: default_value 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 1c41692..3e19268 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 @@ -173,7 +173,7 @@ process: process: value: plugin: format_date - from_format: 'U' + from_format: 'Y-m-d\TH:i:s' to_format: 'Y-m-d' source: value path/alias: source_path 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 index 0ef166d..63762eb 100644 --- a/web/modules/custom/geo_upgrade/src/Plugin/migrate/process/PublicationDateDefault.php +++ b/web/modules/custom/geo_upgrade/src/Plugin/migrate/process/PublicationDateDefault.php @@ -20,7 +20,7 @@ class PublicationDateDefault extends ProcessPluginBase { */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $created_date = $row->getSourceProperty('created'); - if (empty($value)) { + if (!isset($value) || empty($value)) { $value = [0 => ['value' => date('Y-m-d\TH:i:s', $created_date)]]; } return $value;