ept_tiles-1.4.3/ept_tiles.module
ept_tiles.module
<?php /** * @file * Add templates for EPT Tiles. */ /** * Implements hook_theme_registry_alter(). */ function ept_tiles_theme_registry_alter(&$theme_registry) { $ept_module = 'ept_tiles'; $module_path = \Drupal::service('extension.list.module')->getPath($ept_module); $ept_module_with_dashes = str_replace('_', '-', $ept_module); $base_theme = 'paragraph'; $theme_registry['paragraph__ept_tiles_item__default'] = [ 'path' => $module_path . '/templates', 'template' => 'paragraph--ept-tiles-item--default', 'render element' => $theme_registry[$base_theme]['render element'], 'base hook' => $base_theme, 'type' => 'module', 'theme path' => $module_path, 'preprocess functions' => $theme_registry[$base_theme]['preprocess functions'], ]; $base_theme = 'field'; $theme_registry['field__paragraph__field_' . $ept_module . '__' . $ept_module] = [ 'path' => $module_path . '/templates', 'template' => 'field--paragraph--field-' . $ept_module_with_dashes . '--' . $ept_module_with_dashes, 'render element' => $theme_registry[$base_theme]['render element'], 'base hook' => $base_theme, 'type' => 'module', 'theme path' => $module_path, 'preprocess functions' => $theme_registry[$base_theme]['preprocess functions'], ]; } /** * Implements hook_preprocess_paragraph(). */ function ept_tiles_preprocess_paragraph(array &$variables) { // If isn't "ept_tiles_item", skip. if ($variables['paragraph']->bundle() != 'ept_tiles_item') { return; } // If "field_ept_settings" is empty, skip. if ($variables['paragraph']->getParentEntity()->get('field_ept_settings')->isEmpty()) { return; } // Get the 'field_ept_settings' from parent. $ept_settings = $variables['paragraph']->getParentEntity()->get('field_ept_settings')->first()->getValue(); // Default value. $link_in_a_new_tab = FALSE; // If is configured to open in a new tab, return this in a variable. if (!empty($ept_settings['ept_settings']['links']['link_in_a_new_tab'])) { $link_in_a_new_tab = $ept_settings['ept_settings']['links']['link_in_a_new_tab']; } $variables['link_in_a_new_tab'] = $link_in_a_new_tab; }