Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
LayoutBuilderEntityViewDisplayForm | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
create | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
form | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Drupal\display_builder_entity_view\Form; |
6 | |
7 | use Drupal\Core\Form\FormStateInterface; |
8 | use Drupal\Core\Menu\LocalTaskManager; |
9 | use Drupal\Core\Routing\RouteBuilderInterface; |
10 | use Drupal\display_builder\ConfigFormBuilderInterface; |
11 | use Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm as CoreLayoutBuilderEntityViewDisplayForm; |
12 | use Symfony\Component\DependencyInjection\ContainerInterface; |
13 | |
14 | /** |
15 | * Edit form for the entity view display entity type. |
16 | * |
17 | * @internal |
18 | * Form classes are internal. |
19 | */ |
20 | final class LayoutBuilderEntityViewDisplayForm extends CoreLayoutBuilderEntityViewDisplayForm { |
21 | |
22 | use EntityViewDisplayFormTrait; |
23 | |
24 | /** |
25 | * The entity being used by this form. |
26 | * |
27 | * @var \Drupal\display_builder_entity_view\Entity\LayoutBuilderEntityViewDisplay |
28 | */ |
29 | protected $entity; |
30 | |
31 | /** |
32 | * The config form builder for Display Builder. |
33 | */ |
34 | protected ConfigFormBuilderInterface $configFormBuilder; |
35 | |
36 | /** |
37 | * The local task manager. |
38 | */ |
39 | protected LocalTaskManager $localTaskManager; |
40 | |
41 | /** |
42 | * The router builder. |
43 | */ |
44 | protected RouteBuilderInterface $routeBuilder; |
45 | |
46 | /** |
47 | * {@inheritDoc} |
48 | */ |
49 | public static function create(ContainerInterface $container): static { |
50 | $instance = parent::create($container); |
51 | $instance->configFormBuilder = $container->get('display_builder.config_form_builder'); |
52 | $instance->entityTypeManager = $container->get('entity_type.manager'); |
53 | $instance->localTaskManager = $container->get('plugin.manager.menu.local_task'); |
54 | $instance->routeBuilder = $container->get('router.builder'); |
55 | |
56 | return $instance; |
57 | } |
58 | |
59 | /** |
60 | * {@inheritdoc} |
61 | */ |
62 | public function form(array $form, FormStateInterface $form_state): array { |
63 | $form = parent::form($form, $form_state); |
64 | $form = $this->entityViewDisplayForm($form); |
65 | |
66 | if (isset($form['layout'])) { |
67 | $form['layout']['#weight'] = 2; |
68 | $form['layout']['#open'] = $this->entity->isLayoutBuilderEnabled(); |
69 | } |
70 | |
71 | return $form; |
72 | } |
73 | |
74 | } |