-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbt_cms.module
89 lines (75 loc) · 2.9 KB
/
bt_cms.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* @file
* Module file for bt_cms.
*/
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Implements hook_menu_local_actions_alter().
*/
function bt_cms_menu_local_actions_alter(&$local_actions) {
$local_actions['node.add_page']['appears_on'][0] = 'system.admin_content';
}
/**
* Implements hook_entity_base_field_info_alter().
*/
function bt_cms_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
if ($entity_type->id() == 'node') {
if (isset($fields['title'])) {
$fields['title']->setDisplayConfigurable('view', TRUE);
}
}
// Alter the mymodule_text field to use a custom class.
if ($entity_type->id() == 'block_content') {
$fields['info']->setLabel('Block Name');
$fields['info']->setDescription('The name by which the block will be displayed in the list of custom blocks.');
}
}
/**
* Implements hook_entity_type_alter().
*/
function bt_cms_entity_type_alter(array &$entity_types) {
$entity_types['node']->setHandlerClass('route_provider', ['html' => 'Drupal\bt_cms\AlterNodeRouteProvider']);
$entity_types['node']->setHandlerClass('view_builder', 'Drupal\bt_cms\CustomNodeViewBuilder');
}
/**
* Implements hook_node_links_alter().
*/
function bt_cms_node_links_alter(&$links, $entity, &$context) {
if ($entity->getEntityTypeId() == 'node') {
$bundle = $entity->bundle();
$view_mode = $context['view_mode'];
$links['#theme'] = 'links__' . $bundle . '_' . $view_mode;
}
}
/**
* Implements hook_local_tasks_alter().
*/
function bt_cms_local_tasks_alter(&$local_tasks) {
// Update content task to integrate it with our navigation structure.
unset($local_tasks['comment.admin']);
$local_tasks['system.admin_content']['base_route'] = 'bt_cms.website';
$local_tasks['system.admin_content']['route_name'] = 'system.admin_content';
$local_tasks['comment.admin_new']['parent_id'] = 'system.admin_content';
$local_tasks['comment.admin_new']['weight'] = 2;
$local_tasks['comment.admin_approval']['parent_id'] = 'system.admin_content';
$local_tasks['comment.admin_approval']['weight'] = 3;
// Make theme tabs name more specific.
$local_tasks['system.themes_page']['title'] = 'Theme List';
$local_tasks['system.theme_settings']['title'] = 'Theme Settings';
// Disable default tabs of block_content.
unset($local_tasks['entity.block_content.collection']);
unset($local_tasks['block_content.list_sub']);
unset($local_tasks['entity.block_content_type.collection']);
// Move block.admin_display tabs to the system.themes_page tabs group.
$local_tasks['block.admin_display']['base_route'] = 'system.themes_page';
$local_tasks['block.admin_display']['weight'] = 200;
}
/**
* Implements hook_menu_links_discovered_alter().
*/
function bt_cms_menu_links_discovered_alter(&$links) {
// Move block.admin_display menu item inside to the
// system.themes_page menu item.
$links['block.admin_display']['parent'] = 'system.themes_page';
}