Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
19 / 19 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| NameField | |
100.00% |
19 / 19 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| getFieldFormatterMap | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| getFieldWidgetMap | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| processFieldValues | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\name\Plugin\migrate\field; |
| 6 | |
| 7 | use Drupal\migrate\Plugin\MigrationInterface; |
| 8 | use Drupal\migrate_drupal\Attribute\MigrateField; |
| 9 | use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; |
| 10 | |
| 11 | /** |
| 12 | * Name migrate plugin. |
| 13 | */ |
| 14 | #[MigrateField( |
| 15 | id: 'name', |
| 16 | core: [7], |
| 17 | source_module: 'name', |
| 18 | destination_module: 'name', |
| 19 | )] |
| 20 | class NameField extends FieldPluginBase { |
| 21 | |
| 22 | /** |
| 23 | * {@inheritdoc} |
| 24 | */ |
| 25 | public function getFieldFormatterMap() { |
| 26 | return [ |
| 27 | 'name_formatter' => 'name_default', |
| 28 | ]; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * {@inheritdoc} |
| 33 | */ |
| 34 | public function getFieldWidgetMap() { |
| 35 | return [ |
| 36 | 'name_widget' => 'name_default', |
| 37 | ]; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * {@inheritdoc} |
| 42 | */ |
| 43 | public function processFieldValues(MigrationInterface $migration, $field_name, $data) { |
| 44 | $process = [ |
| 45 | 'plugin' => 'iterator', |
| 46 | 'source' => $field_name, |
| 47 | 'process' => [ |
| 48 | 'title' => 'title', |
| 49 | 'given' => 'given', |
| 50 | 'middle' => 'middle', |
| 51 | 'family' => 'family', |
| 52 | 'generational' => 'generational', |
| 53 | 'credentials' => 'credentials', |
| 54 | ], |
| 55 | ]; |
| 56 | $migration->mergeProcessOfProperty($field_name, $process); |
| 57 | } |
| 58 | |
| 59 | } |