' . t('About') . ''; $output .= '

' . t('The Field Layout module allows you to arrange fields into regions on forms and displays of entities such as nodes and users.') . '

'; $output .= '

' . t('For more information, see the online documentation for the Field Layout module.', [':field-layout-documentation' => 'https://www.drupal.org/documentation/modules/field_layout']) . '

'; return $output; } } /** * Implements hook_entity_type_alter(). */ function field_layout_entity_type_alter(array &$entity_types) { /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */ $entity_types['entity_view_display']->setClass(FieldLayoutEntityViewDisplay::class); $entity_types['entity_form_display']->setClass(FieldLayoutEntityFormDisplay::class); // The form classes are only needed when Field UI is installed. if (\Drupal::moduleHandler()->moduleExists('field_ui')) { $entity_types['entity_view_display']->setFormClass('edit', FieldLayoutEntityViewDisplayEditForm::class); $entity_types['entity_form_display']->setFormClass('edit', FieldLayoutEntityFormDisplayEditForm::class); } } /** * Implements hook_entity_view_alter(). */ function field_layout_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) { if ($display instanceof EntityDisplayWithLayoutInterface) { \Drupal::classResolver(FieldLayoutBuilder::class)->buildView($build, $display); } } /** * Implements hook_form_alter(). */ function field_layout_form_alter(&$form, FormStateInterface $form_state, $form_id) { $form_object = $form_state->getFormObject(); if ($form_object instanceof ContentEntityFormInterface && $display = $form_object->getFormDisplay($form_state)) { if ($display instanceof EntityDisplayWithLayoutInterface) { \Drupal::classResolver(FieldLayoutBuilder::class)->buildForm($form, $display); } } }