From c402e0555092dd4b86305e41bb2c14e0d54e85db Mon Sep 17 00:00:00 2001 From: protitude Date: Wed, 12 Jun 2024 17:10:33 -0600 Subject: [PATCH] remove layout restriction for now --- oit.layouts.yml | 2 +- oit.module | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/oit.layouts.yml b/oit.layouts.yml index add295e..c8c45f1 100644 --- a/oit.layouts.yml +++ b/oit.layouts.yml @@ -27,7 +27,7 @@ layout_left_sidebar_section: content: label: Content area layout_both_sidebar_section: - label: 'Both sidebar' + label: 'Both sidebars' path: layouts/both_sidebar_section template: layout--both-sidebar-section library: oit/both_sidebar_section diff --git a/oit.module b/oit.module index ee93857..1d5e416 100644 --- a/oit.module +++ b/oit.module @@ -813,6 +813,25 @@ function oit_menu_local_tasks_alter(&$data, $route_name) { } } +/** + * Implements hook_layouts_alter(). + */ +function oit_layout_alter(&$definitions) { + // an array of layouts to keep + $layoutsWhitelist = ['layout_onecol']; + + // layouts that are required and cannot be removed + $requiredLayouts = ['layout_right_sidebar_section', 'layout_left_sidebar_section', 'layout_both_sidebar_section']; + + $layouts = array_merge($requiredLayouts, $layoutsWhitelist); + + $definitions = array_filter( + $definitions, + static fn(string $id) => in_array($id, $layouts, true), + ARRAY_FILTER_USE_KEY + ); +} + /** * Implements hook_block_access(). */