d532ccbe2bec687c1acf502c6320d3ed180e2522
[yaffs-website] / web / core / modules / file / src / Plugin / migrate / field / d6 / FileField.php
1 <?php
2
3 namespace Drupal\file\Plugin\migrate\field\d6;
4
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\migrate\Row;
7 use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
8
9 /**
10  * @MigrateField(
11  *   id = "filefield",
12  *   core = {6},
13  *   source_module = "filefield",
14  *   destination_module = "file"
15  * )
16  */
17 class FileField extends FieldPluginBase {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function getFieldWidgetMap() {
23     return [
24       'filefield_widget' => 'file_generic',
25     ];
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function getFieldFormatterMap() {
32     return [
33       'default' => 'file_default',
34       'url_plain' => 'file_url_plain',
35       'path_plain' => 'file_url_plain',
36       'image_plain' => 'image',
37       'image_nodelink' => 'image',
38       'image_imagelink' => 'image',
39     ];
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
46     $process = [
47       'plugin' => 'd6_field_file',
48       'source' => $field_name,
49     ];
50     $migration->mergeProcessOfProperty($field_name, $process);
51   }
52
53   /**
54    * {@inheritdoc}
55    */
56   public function getFieldType(Row $row) {
57     return $row->getSourceProperty('widget_type') == 'imagefield_widget' ? 'image' : 'file';
58   }
59
60 }