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