protected function FormAlter::setAllowedLayouts in Layout Builder Restrictions 8.2
Helper function to prepare saved allowed layouts.
Parameters
Drupal\Core\Form\FormStateInterface $form_state: The form state.
Return value
array An array of layout names or empty.
1 call to FormAlter::setAllowedLayouts()
- FormAlter::entityFormEntityBuild in src/
Form/ FormAlter.php - Save allowed blocks & layouts for the given entity view mode.
File
- src/
Form/ FormAlter.php, line 336
Class
- FormAlter
- Supplement form UI to add setting for which blocks & layouts are available.
Namespace
Drupal\layout_builder_restrictions\FormCode
protected function setAllowedLayouts(FormStateInterface $form_state) {
// Set allowed layouts.
$layout_restriction = $form_state
->getValue([
'layout_builder_restrictions',
'allowed_layouts',
'layout_restriction',
]);
$allowed_layouts = [];
if ($layout_restriction == 'restricted') {
$allowed_layouts = array_keys(array_filter($form_state
->getValue([
'layout_builder_restrictions',
'allowed_layouts',
'layouts',
])));
}
return $allowed_layouts;
}