-
Notifications
You must be signed in to change notification settings - Fork 0
/
drimage_improved.install
39 lines (35 loc) · 1.06 KB
/
drimage_improved.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
<?php
/**
* @file
* DrImage update functions.
*/
/**
* Implements hook_install().
*/
function drimage_improved_install(): void {
// Migrate from drimage to drimage_improved.
if (\Drupal::service('module_handler')->moduleExists('drimage')) {
// Replace the 'drimage' field formatter with 'drimage_improved'.
$storage = \Drupal::entityTypeManager()->getStorage('entity_view_display');
$displays = $storage->loadMultiple();
foreach ($displays as $display) {
$components = $display->getComponents();
foreach ($components as $name => $component) {
if (isset($component['type']) && $component['type'] == 'drimage') {
$component['type'] = 'drimage_improved';
$display->setComponent($name, $component);
}
}
$display->save();
}
// Disable the 'drimage' module.
\Drupal::service('module_installer')->uninstall(['drimage']);
}
}
/**
* Implements hook_uninstall().
*/
function drimage_improved_uninstall(): void {
\Drupal::service('drimage_improved.image_style_repository')
->deleteAll();
}