forked from mohankumargupta/mentionsdrupal8module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mentions.install
55 lines (45 loc) · 1.96 KB
/
mentions.install
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
<?php
function defaultenablementionsfilter($config) {
$config = \Drupal::service('config.factory')->getEditable($config);
$filters = $config->get('filters');
$filters['filter_mentions'] = array(
"id" => "filter_mentions",
"provider" => "mentions",
"status" => "true",
"weight" => -40,
"settings" => array(
"mentions_filter" => array(
"UserMentionSpacesInUsername" => "UserMentionSpacesInUsername",
"UserMention" => "UserMention",
"UserMentionByID" => "UserMentionByID"
)
)
);
$config->set('filters',$filters);
$config->save();
}
function defaultenablementionsckeditortoolbar($config) {
$config = \Drupal::service('config.factory')->getEditable($config);
//$settings = $config->get('settings');
$toolbaritems = $config->get('settings.toolbar.rows');
$mentionitemcount = count($toolbaritems[0]) - 1;
if (!isset($toolbaritems[0][$mentionitemcount]['items']['mentionautocomplete'] )) {
$toolbaritems[0][$mentionitemcount]['items'][] = 'mentionsautocomplete';
}
//$toolbaritems = array_values(array_slice($settings['toolbar']['rows'][0], -1))[0];
//if (!isset($toolbaritems['items']['mentionsautocomplete'])) {
// $toolbaritems['items'][] = 'mentionsautocomplete';
//}
//drupal_set_message(print_r($toolbaritems, TRUE));
//$config->set('settings', $settings);
$config->set('settings.toolbar.rows', $toolbaritems);
$config->save();
}
function mentions_install() {
if (!\Drupal::service('config.installer')->isSyncing()) {
defaultenablementionsfilter('filter.format.basic_html');
defaultenablementionsfilter('filter.format.full_html');
defaultenablementionsckeditortoolbar('editor.editor.basic_html');
defaultenablementionsckeditortoolbar('editor.editor.full_html');
}
}