The default value of "field_publication_date" is now the created date

In the issueindex and node story migrations
This commit is contained in:
David Valdez 2019-09-30 14:59:17 -05:00
parent e86c9d99ec
commit b9d4c3c0a4
3 changed files with 35 additions and 2 deletions

View file

@ -165,9 +165,11 @@ process:
# process: # process:
# target_id: tid # target_id: tid
field_publication_date: field_publication_date:
- plugin: publication_date_default
source: field_publication_date
method: process
- -
plugin: sub_process plugin: sub_process
source: created
process: process:
value: value:
plugin: format_date plugin: format_date

View file

@ -213,8 +213,11 @@ process:
# target_id: tid # target_id: tid
field_publication_date: field_publication_date:
- -
plugin: sub_process plugin: publication_date_default
source: field_publication_date source: field_publication_date
method: process
-
plugin: sub_process
process: process:
value: value:
plugin: format_date plugin: format_date

View file

@ -0,0 +1,28 @@
<?php
namespace Drupal\geo_upgrade\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* @MigrateProcessPlugin(
* id = "publication_date_default",
* handle_multiples = TRUE
* )
*/
class PublicationDateDefault extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$created_date = $row->getSourceProperty('created');
if (empty($value)) {
$value = [0 => ['value' => date('Y-m-d\TH:i:s', $created_date)]];
}
return $value;
}
}