3 namespace Drupal\datetime\Plugin\migrate\field\d6;
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 getFieldFormatterMap() {
37 // See d6_field_formatter_settings.yml and
38 // FieldPluginBase::processFieldFormatter().
45 public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
46 switch ($data['type']) {
48 $from_format = 'Y-m-d\TH:i:s';
49 $to_format = 'Y-m-d\TH:i:s';
56 $from_format = 'Y-m-d H:i:s';
57 $to_format = 'Y-m-d\TH:i:s';
60 throw new MigrateException(sprintf('Field %s of type %s is an unknown date field type.', $field_name, var_export($data['type'], TRUE)));
64 'plugin' => 'format_date',
65 'from_format' => $from_format,
66 'to_format' => $to_format,
72 'plugin' => 'iterator',
73 'source' => $field_name,
74 'process' => $process,
76 $migration->mergeProcessOfProperty($field_name, $process);