Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / file / src / Plugin / migrate / field / d6 / FileField.php
diff --git a/web/core/modules/file/src/Plugin/migrate/field/d6/FileField.php b/web/core/modules/file/src/Plugin/migrate/field/d6/FileField.php
new file mode 100644 (file)
index 0000000..930c13b
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+namespace Drupal\file\Plugin\migrate\field\d6;
+
+use Drupal\migrate\Plugin\MigrationInterface;
+use Drupal\migrate\Row;
+use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
+
+/**
+ * @MigrateField(
+ *   id = "filefield",
+ *   core = {6}
+ * )
+ */
+class FileField extends FieldPluginBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFieldWidgetMap() {
+    return [
+      'filefield_widget' => 'file_generic',
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFieldFormatterMap() {
+    return [
+      'default' => 'file_default',
+      'url_plain' => 'file_url_plain',
+      'path_plain' => 'file_url_plain',
+      'image_plain' => 'image',
+      'image_nodelink' => 'image',
+      'image_imagelink' => 'image',
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
+    $process = [
+      'plugin' => 'd6_field_file',
+      'source' => $field_name,
+    ];
+    $migration->mergeProcessOfProperty($field_name, $process);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFieldType(Row $row) {
+    return $row->getSourceProperty('widget_type') == 'imagefield_widget' ? 'image' : 'file';
+  }
+
+}