function lightning_layout_tweak_layout_builder_ui in Lightning Layout 8.2
Tweaks the Layout Builder stuff on an entity view display form.
Parameters
array $element: The form element containing Layout Builder's entity view display options.
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
Return value
array The processed element.
1 string reference to 'lightning_layout_tweak_layout_builder_ui'
File
- ./
lightning_layout.module, line 82 - Contains layout functionality for Lightning.
Code
function lightning_layout_tweak_layout_builder_ui(array $element, FormStateInterface $form_state) {
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */
$display = $form_state
->getFormObject()
->getEntity();
$layout_builder_enabled = $display
->getThirdPartySetting('layout_builder', 'enable', FALSE);
// Check if this display is for an internal view mode.
$view_mode = EntityViewMode::load($display
->getTargetEntityTypeId() . '.' . $display
->getMode());
if ($view_mode) {
$internal = $view_mode
->getThirdPartySetting('lightning_core', 'internal');
if ($internal) {
// If it's not already applied, don't allow Layout Builder.
$element['layout']['#access'] = $layout_builder_enabled;
// Inform the user what's up.
Drupal::messenger()
->addWarning(t('This display is internal and will not be seen by normal users.'));
}
}
return $element;
}