-
Notifications
You must be signed in to change notification settings - Fork 0
/
weeshop_alpha_components.module
51 lines (45 loc) · 1.37 KB
/
weeshop_alpha_components.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @file
* Contains weeshop_alpha_components.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function weeshop_alpha_components_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the weeshop_alpha_components module.
case 'help.page.weeshop_alpha_components':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Provides components for WeeShop Aplha theme support perpose.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function weeshop_alpha_components_theme() {
return [
'weeshop_alpha_components_photo_gallery' => [
'variables' => ['images' => []]
],
];
}
/**
* Implements hook_entity_base_field_info_alter()
*/
function weeshop_alpha_components_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {
// Alter product detail images to use weeshop_alpha_components_photo_gallery formatter
if ($entity_type->id() === 'commerce_product' && !empty($fields['detail_images'])) {
//throw new \Exception(get_class($fields['detail_images']));
$fields['detail_images']
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'weeshop_alpha_components_photo_gallery',
'weight' => -6
]);
}
}