Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| PrimaryEntityReferenceFormatterHooks | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| fieldFormatterInfoAlter | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\primary_entity_reference\Hook; |
| 6 | |
| 7 | use Drupal\Core\Hook\Attribute\Hook; |
| 8 | |
| 9 | /** |
| 10 | * Field formatter hook implementations for primary_entity_reference. |
| 11 | */ |
| 12 | class PrimaryEntityReferenceFormatterHooks { |
| 13 | |
| 14 | /** |
| 15 | * Implements hook_field_formatter_info_alter(). |
| 16 | */ |
| 17 | #[Hook('field_formatter_info_alter')] |
| 18 | public function fieldFormatterInfoAlter(array &$info): void { |
| 19 | foreach ($info as $key => $formatter_info) { |
| 20 | if (in_array('entity_reference', $formatter_info['field_types'], TRUE)) { |
| 21 | $info[$key]['field_types'][] = 'primary_entity_reference'; |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | } |