1c3e25c9563c00d92ddc00370d02a6d8521410c1
[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 @trigger_error('FileField is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\field\d7\FileField instead.', E_USER_DEPRECATED);
6
7 use Drupal\migrate\Plugin\MigrationInterface;
8 use Drupal\migrate\Row;
9 use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
10
11 /**
12  * @MigrateCckField(
13  *   id = "file",
14  *   core = {7}
15  * )
16  *
17  * @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
18  * \Drupal\file\Plugin\migrate\field\d7\FileField instead.
19  *
20  * @see https://www.drupal.org/node/2751897
21  */
22 class FileField extends CckFieldPluginBase {
23
24   /**
25    * {@inheritdoc}
26    */
27   public function getFieldWidgetMap() {
28     return [
29       'filefield_widget' => 'file_generic',
30     ];
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function getFieldFormatterMap() {
37     return [
38       'default' => 'file_default',
39       'url_plain' => 'file_url_plain',
40       'path_plain' => 'file_url_plain',
41       'image_plain' => 'image',
42       'image_nodelink' => 'image',
43       'image_imagelink' => 'image',
44     ];
45   }
46
47   /**
48    * {@inheritdoc}
49    */
50   public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
51     $process = [
52       'plugin' => 'sub_process',
53       'source' => $field_name,
54       'process' => [
55         'target_id' => 'fid',
56         'display' => 'display',
57         'description' => 'description',
58       ],
59     ];
60     $migration->mergeProcessOfProperty($field_name, $process);
61   }
62
63   /**
64    * {@inheritdoc}
65    */
66   public function getFieldType(Row $row) {
67     return $row->getSourceProperty('widget_type') == 'imagefield_widget' ? 'image' : 'file';
68   }
69
70 }