Views Cleanup
No security coverage
Views ecosystem
This module provides tools to easily clean up and manage Views, such as removing specific filters or replacing them with new configurations. It can also help with cleaning up View dependencies when uninstalling modules.
This module is initally created for helping uninstall module: multiversion
Add some services to cleanup views easily
Services:
- views_cleanup.filter_cleanup
- views_cleanup.filter_replacement
- views_cleanup.filter_add
- views_cleanup.aggregate_views_filter_option
- views_cleanup.denpendencies
- views_cleanup.fields_cleanup
Examples
\Drupal::service('views_cleanup.filter_cleanup')
->cleanupViewsFiltersByFilterCheckOptions(['entity_field' => '_deleted']);
\Drupal::service('views_cleanup.denpendencies')
->cleanupViewsDependencyModules(['multiversion']);
$new_filter_config = [
'id' => 'deleted',
'table' => 'node_field_data',
'field' => 'deleted',
'relationship' => 'none',
'group_type' => 'group',
'admin_label' => '',
'entity_type' => 'node',
'entity_field' => 'deleted',
'plugin_id' => 'date',
'operator' => 'not empty',
'value' => ['min' => '', 'max' => '', 'value' => '', 'type' => 'date',],
'group' => 1,
'exposed' => FALSE,
'expose' => [
'operator_id' => '',
'label' => '',
'description' => '',
'use_operator' => FALSE,
'operator' => '',
'operator_limit_selection' => FALSE,
'operator_list' => [],
'identifier' => '',
'required' => FALSE,
'remember' => FALSE,
'multiple' => FALSE,
'remember_roles' => ['authenticated' => 'authenticated',],
'min_placeholder' => '',
'max_placeholder' => '',
'placeholder' => '',
],
'is_grouped' => FALSE,
'group_info' => [
'label' => '',
'description' => '',
'identifier' => '',
'optional' => TRUE,
'widget' => 'select',
'multiple' => FALSE,
'remember' => FALSE,
'default_group' => 'All',
'default_group_multiple' => [],
'group_items' => [],
],
];
\Drupal::service('views_cleanup.filter_replacement')
->replaceViewsFilterByFilterCheckOptions([
'entity_type' => 'node',
'entity_field' => '_deleted',
'operator' => '=',
'value' => '1',
], 'deleted', $new_filter_config);