protected function OverridesEntityForm::buildMessage in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Form/OverridesEntityForm.php \Drupal\layout_builder\Form\OverridesEntityForm::buildMessage()
- 9 core/modules/layout_builder/src/Form/OverridesEntityForm.php \Drupal\layout_builder\Form\OverridesEntityForm::buildMessage()
Renders a message to display at the top of the layout builder.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity whose layout is being edited.
\Drupal\layout_builder\OverridesSectionStorageInterface $section_storage: The current section storage.
Return value
array A renderable array containing the message.
1 call to OverridesEntityForm::buildMessage()
- OverridesEntityForm::buildForm in core/
modules/ layout_builder/ src/ Form/ OverridesEntityForm.php - Form constructor.
File
- core/
modules/ layout_builder/ src/ Form/ OverridesEntityForm.php, line 122
Class
- OverridesEntityForm
- Provides a form containing the Layout Builder UI for overrides.
Namespace
Drupal\layout_builder\FormCode
protected function buildMessage(EntityInterface $entity, OverridesSectionStorageInterface $section_storage) {
$entity_type = $entity
->getEntityType();
$bundle_info = $this->entityTypeBundleInfo
->getBundleInfo($entity
->getEntityTypeId());
$variables = [
'@bundle' => $bundle_info[$entity
->bundle()]['label'],
'@singular_label' => $entity_type
->getSingularLabel(),
'@plural_label' => $entity_type
->getPluralLabel(),
];
$defaults_link = $section_storage
->getDefaultSectionStorage()
->getLayoutBuilderUrl();
if ($defaults_link
->access($this
->currentUser())) {
$variables[':link'] = $defaults_link
->toString();
if ($entity_type
->hasKey('bundle')) {
$message = $this
->t('You are editing the layout for this @bundle @singular_label. <a href=":link">Edit the template for all @bundle @plural_label instead.</a>', $variables);
}
else {
$message = $this
->t('You are editing the layout for this @singular_label. <a href=":link">Edit the template for all @plural_label instead.</a>', $variables);
}
}
else {
if ($entity_type
->hasKey('bundle')) {
$message = $this
->t('You are editing the layout for this @bundle @singular_label.', $variables);
}
else {
$message = $this
->t('You are editing the layout for this @singular_label.', $variables);
}
}
return [
'#type' => 'container',
'#attributes' => [
'class' => [
'layout-builder__message',
'layout-builder__message--overrides',
],
],
'message' => [
'#theme' => 'status_messages',
'#message_list' => [
'status' => [
$message,
],
],
'#status_headings' => [
'status' => $this
->t('Status message'),
],
],
'#weight' => -900,
];
}