drowl_paragraphs_bs-1.x-dev/modules/drowl_paragraphs_bs_type_tabs_accordion/drowl_paragraphs_bs_type_tabs_accordion.module
modules/drowl_paragraphs_bs_type_tabs_accordion/drowl_paragraphs_bs_type_tabs_accordion.module
<?php
/**
* @file
* Drowl_paragraphs_bs_type_tabs_accordion module.
*/
/**
* Pass ui_styles modifier classes to the various wrappers.
*/
function drowl_paragraphs_bs_type_tabs_accordion_preprocess_paragraph(&$variables) {
if ($variables['paragraph']->bundle() == 'container_tabs_accordion') {
if (isset($variables['attributes']['class'])) {
foreach ($variables['attributes']['class'] as $class) {
if (str_starts_with($class, 'tabs-acc__type-')) {
$variables['tabs_acc_type'] = str_replace('tabs-acc__type-', '', $class);
$variables['attributes']->removeClass($class);
}
elseif (str_starts_with($class, 'tabs-acc__init-state-')) {
$variables['tabs_acc_init_state'] = str_replace('tabs-acc__init-state-', '', $class);
}
elseif ($class === 'tabs-acc__multiple-open') {
$variables['tabs_acc_allow_multiple_open'] = TRUE;
}
elseif (str_starts_with($class, 'tabs-acc__tabs-style-')) {
$variables['tabs_acc_tabs_style'] = str_replace('tabs-acc__tabs-style-', '', $class);
$variables['attributes']->removeClass($class);
}
elseif (str_starts_with($class, 'tabs-acc__accordion-style-')) {
$variables['tabs_acc_accordion_style'] = str_replace('tabs-acc__accordion-style-', '', $class);
}
}
}
}
}
/**
* Implements hook_theme().
*/
function drowl_paragraphs_bs_type_tabs_accordion_theme($existing, $type, $theme, $path) {
$templates = $path . '/templates';
return [
'paragraph__drowl_paragraphs_bs__container_tabs_accordion' => [
'base hook' => 'paragraph',
'path' => $templates,
],
'paragraph__drowl_paragraphs_bs__container_tabs_accordion_subtab' => [
'base hook' => 'paragraph',
'path' => $templates,
],
];
}
