summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/migrate_drupal/src/Attribute/MigrateField.php
blob: ffc646b21222f4bf3504112cd8147ce1514a0fe3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php

declare(strict_types=1);

namespace Drupal\migrate_drupal\Attribute;

use Drupal\Component\Plugin\Attribute\Plugin;

/**
 * Defines a field plugin attribute object.
 *
 * Field plugins are responsible for handling the migration of custom fields
 * (provided by Field API in Drupal 7) to Drupal 8+. They are allowed to alter
 * fieldable entity migrations when these migrations are being generated, and
 * can compute destination field types for individual fields during the actual
 * migration process.
 *
 * Plugin Namespace: Plugin\migrate\field
 *
 * For a working example, see
 * \Drupal\datetime\Plugin\migrate\field\DateField
 *
 * @see \Drupal\migrate\Plugin\MigratePluginManager
 * @see \Drupal\migrate_drupal\Plugin\MigrateFieldInterface;
 * @see \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase
 * @see plugin_api
 *
 * @ingroup migration
 */
#[\Attribute(\Attribute::TARGET_CLASS)]
class MigrateField extends Plugin {

  /**
   * The plugin definition.
   *
   * @var array
   */
  protected $definition;

  /**
   * Constructs a migrate field attribute object.
   *
   * @param string $id
   *   A unique identifier for the field plugin.
   * @param int[] $core
   *   (optional) The Drupal core version(s) this plugin applies to.
   * @param int $weight
   *   (optional) The weight of this plugin relative to other plugins servicing
   *   the same field type and core version. The lowest weighted applicable
   *   plugin will be used for each field.
   * @param string[] $type_map
   *   (optional) Map of D6 and D7 field types to D8+ field type plugin IDs.
   * @param string|null $source_module
   *   (optional) Identifies the system providing the data the field plugin will
   *   read. The source_module is expected to be the name of a Drupal module
   *   that must be installed in the source database.
   * @param string|null $destination_module
   *   (optional) Identifies the system handling the data the destination plugin
   *   will write. The destination_module is expected to be the name of a Drupal
   *   module on the destination site that must be installed.
   * @param class-string|null $deriver
   *   (optional) The deriver class.
   */
  public function __construct(
    public readonly string $id,
    public readonly array $core = [6],
    public readonly int $weight = 0,
    public readonly array $type_map = [],
    public readonly ?string $source_module = NULL,
    public readonly ?string $destination_module = NULL,
    public readonly ?string $deriver = NULL,
  ) {}

}