This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colorapi.module
64 lines (58 loc) · 1.6 KB
/
colorapi.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
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @file
* Holds hooks for the Color API module.
*/
/**
* Implements hook_theme().
*/
function colorapi_theme($existing, $type, $theme, $path) {
return [
'colorapi_color_display' => [
'variables' => [
'delta' => NULL,
'item' => NULL,
'hexadecimal_color' => NULL,
],
'template' => 'colorapi-color-display',
],
'colorapi_text_display' => [
'variables' => [
'delta' => NULL,
'item' => NULL,
'hexadecimal_color' => NULL,
],
'template' => 'colorapi-text-display',
],
];
}
/**
* Implements hook_entity_type_alter().
*/
function colorapi_entity_type_alter(array &$entity_types) {
// If the Color entity is disabled, remove the Color entity type.
$color_entity_enabled = \Drupal::config('colorapi.settings')->get('enable_color_entity');
if (!$color_entity_enabled) {
unset($entity_types['colorapi_color']);
}
}
/**
* Implements hook_menu_links_discovered_alter().
*/
function colorapi_menu_links_discovered_alter(&$links) {
// If the Color entity is disabled, items from the config page.
$color_entity_enabled = \Drupal::config('colorapi.settings')->get('enable_color_entity');
if (!$color_entity_enabled) {
unset($links['entity.coloreapi_color.collection']);
}
}
/**
* Implements hook_field_info_alter().
*/
function colorapi_field_info_alter(&$info) {
// If the Color field is disabled, remove the Color field type.
$color_field_enabled = \Drupal::config('colorapi.settings')->get('enable_color_field');
if (!$color_field_enabled) {
unset($info['colorapi_color_field']);
}
}