Add the "publication date" default value in the blog and gleaning types

This commit is contained in:
David Valdez 2019-09-30 15:24:54 -05:00
parent b07c74d77e
commit 42d6b6c757
4 changed files with 24 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;