Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| EntityViewDisplay | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\display_builder_entity_view\Entity; |
| 6 | |
| 7 | use Drupal\Core\Entity\Entity\EntityViewDisplay as CoreEntityViewDisplay; |
| 8 | use Drupal\Core\Entity\EntityTypeManagerInterface; |
| 9 | use Drupal\display_builder\DisplayBuildablePluginManager; |
| 10 | use Drupal\display_builder\InstanceInterface; |
| 11 | use Drupal\display_builder_entity_view\BuilderDataConverter; |
| 12 | use Drupal\ui_patterns\Element\ComponentElementBuilder; |
| 13 | use Drupal\ui_patterns\SourcePluginManager; |
| 14 | |
| 15 | /** |
| 16 | * Provides an entity view display entity that has a display builder. |
| 17 | * |
| 18 | * When Layout Builder is not activated, extends the default entity view |
| 19 | * display ("Manage display"). |
| 20 | * |
| 21 | * @see \Drupal\display_builder_entity_view\Hook\DisplayBuilderEntityViewHook::entityTypeAlter() |
| 22 | * @see \Drupal\display_builder_entity_view\Entity\LayoutBuilderEntityViewDisplay |
| 23 | */ |
| 24 | class EntityViewDisplay extends CoreEntityViewDisplay implements DisplayBuilderEntityDisplayInterface { |
| 25 | |
| 26 | use EntityViewDisplayTrait; |
| 27 | |
| 28 | /** |
| 29 | * The source plugin manager. |
| 30 | */ |
| 31 | protected SourcePluginManager $sourcePluginManager; |
| 32 | |
| 33 | /** |
| 34 | * The loaded display builder instance. |
| 35 | */ |
| 36 | protected ?InstanceInterface $instance; |
| 37 | |
| 38 | /** |
| 39 | * The entity type manager. |
| 40 | */ |
| 41 | protected EntityTypeManagerInterface $entityTypeManager; |
| 42 | |
| 43 | /** |
| 44 | * The component element builder service. |
| 45 | */ |
| 46 | protected ComponentElementBuilder $componentElementBuilder; |
| 47 | |
| 48 | /** |
| 49 | * The data converter from Manage Display and Layout Builder. |
| 50 | */ |
| 51 | protected BuilderDataConverter $dataConverter; |
| 52 | |
| 53 | /** |
| 54 | * The display buildable plugin manager. |
| 55 | */ |
| 56 | protected DisplayBuildablePluginManager $displayBuildableManager; |
| 57 | |
| 58 | /** |
| 59 | * Constructs the EntityViewDisplay. |
| 60 | * |
| 61 | * @param array $values |
| 62 | * The values to initialize the entity with. |
| 63 | * @param string $entity_type |
| 64 | * The entity type ID. |
| 65 | */ |
| 66 | public function __construct(array $values, $entity_type) { |
| 67 | parent::__construct($values, $entity_type); |
| 68 | $this->sourcePluginManager = \Drupal::service('plugin.manager.ui_patterns_source'); |
| 69 | $this->entityTypeManager = \Drupal::service('entity_type.manager'); |
| 70 | $this->componentElementBuilder = \Drupal::service('ui_patterns.component_element_builder'); |
| 71 | $this->dataConverter = \Drupal::service('display_builder_entity_view.builder_data_converter'); |
| 72 | $this->displayBuildableManager = \Drupal::service('plugin.manager.display_buildable'); |
| 73 | } |
| 74 | |
| 75 | } |