3 namespace Drupal\datetime\Plugin\migrate\field;
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\migrate\MigrateException;
7 use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
13 * "date" = "datetime",
14 * "datestamp" = "timestamp",
15 * "datetime" = "datetime",
20 class DateField extends FieldPluginBase {
25 public function getFieldWidgetMap() {
27 'date' => 'datetime_default',
28 'datetime' => 'datetime_default',
29 'datestamp' => 'datetime_timestamp',
36 public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
37 switch ($data['type']) {
39 $from_format = 'Y-m-d\TH:i:s';
40 $to_format = 'Y-m-d\TH:i:s';
47 $from_format = 'Y-m-d H:i:s';
48 $to_format = 'Y-m-d\TH:i:s';
51 throw new MigrateException(sprintf('Field %s of type %s is an unknown date field type.', $field_name, var_export($data['type'], TRUE)));
55 'plugin' => 'format_date',
56 'from_format' => $from_format,
57 'to_format' => $to_format,
63 'plugin' => 'sub_process',
64 'source' => $field_name,
65 'process' => $process,
67 $migration->mergeProcessOfProperty($field_name, $process);