gin_type_tray-1.0.x-dev/gin_type_tray.module
gin_type_tray.module
<?php use Drupal\Core\Url; /** * @file * Primary module hooks for Gin Type Tray module. */ function gin_type_tray_theme_registry_alter(&$theme_registry) { if (isset($theme_registry['type_tray_teaser'])) { $theme_registry['type_tray_teaser']['template'] = 'type-tray-teaser'; $theme_registry['type_tray_teaser']['path'] = \Drupal::service('extension.list.module')->getPath('gin_type_tray') . '/templates'; $theme_registry['type_tray_teaser']['variables']['content_type_name'] = 'Test'; } if(isset($theme_registry['type_tray_page'])) { $theme_registry['type_tray_page']['template'] = 'type-tray-page'; $theme_registry['type_tray_page']['path'] = \Drupal::service('extension.list.module')->getPath('gin_type_tray') . '/templates'; $theme_registry['type_tray_page']['variables']['node_add_page_url_grid'] = Url::fromRoute('node.add_page', ['layout' => 'grid']); $theme_registry['type_tray_page']['variables']['node_add_page_url_list'] = Url::fromRoute('node.add_page', ['layout' => 'list']); } } /* * Implements hook_preprocess(). */ function gin_type_tray_preprocess_type_tray_teaser(&$vars) { $icon_ext = pathinfo($vars['icon_url'], PATHINFO_EXTENSION); $vars['icon_filetype'] = $icon_ext; } /** * Implements hook_library_info_alter(). */ function gin_type_tray_library_info_alter(&$libraries, $module) { if ($module === 'type_tray') { if (isset($libraries['type_tray'])) { $library_path = \Drupal::service('extension.list.module')->getPath('gin_type_tray'); $libraries['type_tray']['css']['theme'] = [ '/' . $library_path . '/css/gin_type_tray.css' => ['weight' => 1], ]; } } }