e6b3682eb0bb1e8e3575e956f0b3f8d2eb130884
[yaffs-website] / destination / EntityBaseFieldOverride.php
1 <?php
2
3 namespace Drupal\migrate\Plugin\migrate\destination;
4
5 use Drupal\migrate\Row;
6
7 /**
8  * Provides entity base field override destination plugin.
9  *
10  * Base fields are non-configurable fields that always exist on a given entity
11  * type, like the 'title', 'created' and 'sticky' fields of the 'node' entity
12  * type. Some entity types can have bundles, for example the node content types.
13  * The base fields exist on all bundles but the bundles can override the
14  * definitions. For example, the label for node 'title' base field can be
15  * different on different content types.
16  *
17  * Example:
18  *
19  * The example below migrates the node 'sticky' settings for each content type.
20  * @code
21  * id: d6_node_setting_sticky
22  * label: Node type 'sticky' setting
23  * migration_tags:
24  *   - Drupal 6
25  * source:
26  *   plugin: d6_node_type
27  *   constants:
28  *     entity_type: node
29  *     field_name: sticky
30  * process:
31  *   entity_type: 'constants/entity_type'
32  *   bundle: type
33  *   field_name: 'constants/field_name'
34  *   label:
35  *     plugin: default_value
36  *     default_value: 'Sticky at the top of lists'
37  *   'default_value/0/value': 'options/sticky'
38  * destination:
39  *   plugin: entity:base_field_override
40  * migration_dependencies:
41  *   required:
42  *     - d6_node_type
43  * @endcode
44  *
45  * @MigrateDestination(
46  *   id = "entity:base_field_override"
47  * )
48  */
49 class EntityBaseFieldOverride extends EntityConfigBase {
50
51   /**
52    * {@inheritdoc}
53    */
54   protected function getEntityId(Row $row) {
55     $entity_type = $row->getDestinationProperty('entity_type');
56     $bundle = $row->getDestinationProperty('bundle');
57     $field_name = $row->getDestinationProperty('field_name');
58     return "$entity_type.$bundle.$field_name";
59   }
60
61 }