-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautocomplete_deluxe.install
43 lines (34 loc) · 1.03 KB
/
autocomplete_deluxe.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
<?php
/**
* @file
* Install, update and uninstall functions for the Autocomplete Deluxe module.
*/
use Drupal\Core\Entity\Entity\EntityFormDisplay;
/**
* Rename the limit setting to match_limit.
*/
function autocomplete_deluxe_update_8001() {
$updateCount = 0;
foreach (EntityFormDisplay::loadMultiple() as $formDisplay) {
$changed = FALSE;
foreach ($formDisplay->getComponents() as $fieldName => $component) {
if (!isset($component['type']) || $component['type'] !== 'autocomplete_deluxe') {
continue;
}
if (!isset($component['settings']['limit'])) {
continue;
}
if (isset($component['settings']['match_limit'])) {
continue;
}
$component['settings']['match_limit'] = (int) $component['settings']['limit'];
$formDisplay->setComponent($fieldName, $component);
$changed = TRUE;
$updateCount++;
}
if ($changed) {
$formDisplay->save();
}
}
return sprintf('Updated the settings of %d Autocomplete Deluxe widgets.', $updateCount);
}