commercetools-8.x-1.2-alpha1/modules/commercetools_demo/commercetools_demo.module
modules/commercetools_demo/commercetools_demo.module
<?php
/**
* @file
* Defines the commercetools_demo module hooks.
*/
/**
* Implements hook_page_attachments().
*/
function commercetools_demo_page_attachments(array &$attachments) {
$attachments['#attached']['library'][] = 'commercetools_demo/global';
$attachments['#attached']['library'][] = 'commercetools_demo/product_attribute_subscriber';
}
/**
* Implements hook_theme().
*/
function commercetools_demo_theme() {
return [
'commercetools_filter_label__demo' => [
'variables' => [
'label' => NULL,
],
],
'commercetools_filter_option__demo' => [
'variables' => [
'label' => NULL,
'count' => NULL,
'key' => NULL,
],
],
'commercetools_product_attribute_label__demo' => [
'variables' => [
'label' => NULL,
'key' => NULL,
],
],
'menu__commercetools_content_categories_list__bootstrap' => [
'template' => 'commercetools-categories-list--demo',
'base hook' => 'menu',
],
'commercetools_locales_block__demo' => [
'variables' => [
'header' => NULL,
'links' => NULL,
],
],
];
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for commercetools_filter_option templates.
*/
function commercetools_demo_theme_suggestions_commercetools_filter_option_alter(array &$suggestions, array $variables) {
$suggestions[] = 'commercetools_filter_option__demo';
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for commercetools_product_attribute_label templates.
*/
function commercetools_demo_theme_suggestions_commercetools_product_attribute_label_alter(array &$suggestions, array $variables) {
$suggestions[] = 'commercetools_product_attribute_label__demo';
}
/**
* Fixes Bootstrap theme issue with rendering sidebar menus as horizontal.
*
* Implements hook_preprocess_HOOK() for commercetools_filter_label__demo templates.
*/
function commercetools_demo_preprocess_menu__commercetools_content_categories_list(array &$variables) {
$variables['attributes']['class'][] = 'flex-column';
}
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function commercetools_demo_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
if ($variables['theme_hook_original'] == 'menu__commercetools_content_categories_list') {
$theme = \Drupal::theme()->getActiveTheme()->getName();
if (in_array($theme, [
'bootstrap',
'flexistyle_bootstrap',
'bootstrap5',
'bootstrap_barrio',
])) {
$suggestions[] = $variables['theme_hook_original'] . '__bootstrap';
}
}
}
