getRouteObject()->getOption('_layout_builder')) { $output = '

' . t('This layout builder tool allows you to configure the layout of the main content area.') . '

'; if (\Drupal::currentUser()->hasPermission('administer blocks')) { $output .= '

' . t('To manage other areas of the page, use the block administration page.', ['@block-ui' => Url::fromRoute('block.admin_display')->toString()]) . '

'; } else { $output .= '

' . t('To manage other areas of the page, use the block administration page.') . '

'; } return $output; } switch ($route_name) { case 'help.page.layout_builder': $output = '

' . t('About') . '

'; $output .= '

' . t('Layout Builder provides layout building utility.') . '

'; $output .= '

' . t('For more information, see the online documentation for the Layout Builder module.', [':layout-builder-documentation' => 'https://www.drupal.org/docs/8/core/modules/layout_builder']) . '

'; return $output; } } /** * Implements hook_entity_type_alter(). */ function layout_builder_entity_type_alter(array &$entity_types) { /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */ $entity_types['entity_view_display'] ->setClass(LayoutBuilderEntityViewDisplay::class) ->setStorageClass(LayoutBuilderEntityViewDisplayStorage::class) ->setFormClass('edit', LayoutBuilderEntityViewDisplayForm::class); } /** * Implements hook_form_FORM_ID_alter() for \Drupal\field_ui\Form\EntityFormDisplayEditForm. */ function layout_builder_form_entity_form_display_edit_form_alter(&$form, FormStateInterface $form_state) { // Hides the Layout Builder field. It is rendered directly in // \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::buildMultiple(). unset($form['fields']['layout_builder__layout']); $key = array_search('layout_builder__layout', $form['#fields']); if ($key !== FALSE) { unset($form['#fields'][$key]); } } /** * Implements hook_field_config_insert(). */ function layout_builder_field_config_insert(FieldConfigInterface $field_config) { // Clear the sample entity for this entity type and bundle. $sample_entity_generator = \Drupal::service('layout_builder.sample_entity_generator'); $sample_entity_generator->delete($field_config->getTargetEntityTypeId(), $field_config->getTargetBundle()); \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } /** * Implements hook_field_config_delete(). */ function layout_builder_field_config_delete(FieldConfigInterface $field_config) { // Clear the sample entity for this entity type and bundle. $sample_entity_generator = \Drupal::service('layout_builder.sample_entity_generator'); $sample_entity_generator->delete($field_config->getTargetEntityTypeId(), $field_config->getTargetBundle()); \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); }