function thunder_liveblog_module_preinstall in Thunder 8.4
Same name and namespace in other branches
- 8.5 modules/thunder_liveblog/thunder_liveblog.install \thunder_liveblog_module_preinstall()
- 8.2 modules/thunder_liveblog/thunder_liveblog.install \thunder_liveblog_module_preinstall()
- 8.3 modules/thunder_liveblog/thunder_liveblog.install \thunder_liveblog_module_preinstall()
- 6.2.x modules/thunder_liveblog/thunder_liveblog.install \thunder_liveblog_module_preinstall()
- 6.0.x modules/thunder_liveblog/thunder_liveblog.install \thunder_liveblog_module_preinstall()
- 6.1.x modules/thunder_liveblog/thunder_liveblog.install \thunder_liveblog_module_preinstall()
Delete liveblog provided config, we have our own.
File
- modules/
thunder_liveblog/ thunder_liveblog.install, line 44 - The install file.
Code
function thunder_liveblog_module_preinstall($module) {
if ('thunder_liveblog' == $module) {
$entity_query = \Drupal::entityQuery('node');
$results = $entity_query
->condition('type', 'liveblog')
->exists('body')
->count()
->execute();
if (($field = FieldConfig::load('node.liveblog.body')) && !$results) {
$field
->delete();
field_purge_batch(10);
}
$configs = [
'core.entity_form_display.node.liveblog.default',
'core.entity_form_display.liveblog_post.liveblog_post.default',
'core.entity_view_display.liveblog_post.liveblog_post.default',
'core.entity_view_display.node.liveblog.default',
];
$configFactory = \Drupal::configFactory();
foreach ($configs as $config) {
$configFactory
->getEditable($config)
->delete();
}
}
}