forked from srijanone/ezcontent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathezcontent.install
73 lines (67 loc) · 2.53 KB
/
ezcontent.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* @file
* Install, update/uninstall functions for the EZ Content profile.
*/
/**
* Configuration changes post update of field group module to 3.x.
*/
function ezcontent_update_8001() {
/** @var \Drupal\update_helper\Updater $updateHelper */
$updateHelper = \Drupal::service('update_helper.updater');
// Execute configuration update definitions with logging of success.
$updateHelper->executeUpdate('ezcontent', 'ezcontent_update_8001');
// Output logged messages to related channel of update execution.
return $updateHelper->logger()->output();
}
/**
* Configuration changes for update from 1.2 to 1.3.
*/
function ezcontent_update_8002() {
// Remove module entries from core.extension config for modules that are no
// longer part of ezcontent profile.
$module_data = \Drupal::config('core.extension')->get('module');
unset($module_data['default_content'], $module_data['ezcontent_demo'], $module_data['moderation_note']);
\Drupal::configFactory()->getEditable('core.extension')
->set('module', $module_data)
->save();
// Remove module entries from key_value table for modules that are no longer
// part of ezcontent profile.
$modules = [
'default_content',
'ezcontent_demo',
'moderation_note',
];
\Drupal::database()->delete('key_value')
->condition('collection', 'system.schema')
->condition('name', $modules, 'IN')
->execute();
// Install gin theme.
\Drupal::service('theme_installer')->install(['gin']);
// Install gin toolbar.
\Drupal::service('module_installer')->install(['gin_toolbar']);
}
/**
* Remove entries for deprecated service from database, if any.
*/
function ezcontent_update_8003() {
// Check for all the routes in the router table and delete the ones that have
// "paramconverter.latest_revision" service registered as a converter in the
// parameters options for the route.
$routes = \Drupal::database()->select('router', 'r')
->fields('r', ['name', 'route'])
->execute()->fetchAll();
foreach ($routes as $route) {
$unserialized_routes = $ur_options = [];
$unserialized_routes = unserialize($route->route);
$ur_options = $unserialized_routes->getOptions();
if (isset($ur_options['parameters'])) {
if (isset($ur_options['parameters'][key($ur_options['parameters'])]['converter'])
&& $ur_options['parameters'][key($ur_options['parameters'])]['converter'] === 'paramconverter.latest_revision') {
\Drupal::database()->delete('router')
->condition('name', $route->name)
->execute();
}
}
}
}