Skip to content
Snippets Groups Projects
Commit 02a1c3e2 authored by Brian Canini's avatar Brian Canini
Browse files

Updating drupal/views_bulk_operations (3.4.0 => 3.8.0)

parent 8553f256
No related branches found
No related tags found
No related merge requests found
......@@ -2,12 +2,12 @@ name: 'Views Bulk Operations test'
type: module
description: 'Support module for testing Views Bulk Operations.'
package: Testing
core: 8.x
core_version_requirement: ^8.8 || ^9
dependencies:
- drupal:views_bulk_operations
- drupal:node
# Information added by Drupal.org packaging script on 2020-02-04
version: '8.x-3.4'
# Information added by Drupal.org packaging script on 2020-06-04
version: '8.x-3.8'
project: 'views_bulk_operations'
datestamp: 1580807961
datestamp: 1591296882
......@@ -2,11 +2,11 @@ type: module
name: 'Views Bulk Operations'
description: 'Adds an ability to perform bulk operations on selected entities from view results.'
package: 'Views'
core: 8.x
core_version_requirement: ^8.8 || ^9
dependencies:
- drupal:views (>=8.5)
- drupal:views
# Information added by Drupal.org packaging script on 2020-02-04
version: '8.x-3.4'
# Information added by Drupal.org packaging script on 2020-06-04
version: '8.x-3.8'
project: 'views_bulk_operations'
datestamp: 1580807961
datestamp: 1591296882
<?php
/**
* @file
* Contains update procedures for the module.
*/
/**
* Convert configuration of existing views to the new schema.
*/
function views_bulk_operations_update_8034(&$sandbox) {
$viewsStorage = \Drupal::service('entity_type.manager')->getStorage('view');
if (!isset($sandbox['current'])) {
$sandbox['total'] = $viewsStorage->getQuery()->count()->execute();
$sandbox['current'] = 0;
$sandbox['converted'] = 0;
}
$query = $viewsStorage->getQuery();
// Process 10 view configs at a time.
$query->range($sandbox['current'], 10);
$results = $query->execute();
if (!empty($results)) {
foreach ($results as $view_id) {
$view = $viewsStorage->load($view_id);
$displays = $view->get('display');
$converted = FALSE;
foreach ($displays as $display_id => &$display) {
if (!empty($display['display_options']['fields'])) {
foreach ($display['display_options']['fields'] as $field_id => &$field) {
if ($field['plugin_id'] === 'views_bulk_operations_bulk_form') {
$new_selected_actions = [];
foreach ($field['selected_actions'] as $plugin_id) {
if (!$plugin_id) {
continue;
}
$action_config_array = ['action_id' => $plugin_id];
if (isset($field['preconfiguration']) && isset($field['preconfiguration'][$plugin_id])) {
$action_config_array['preconfiguration'] = $field['preconfiguration'][$plugin_id];
}
$new_selected_actions[] = $action_config_array;
}
$field['selected_actions'] = $new_selected_actions;
unset($field['preconfiguration']);
$converted = TRUE;
}
}
}
}
if ($converted) {
$view->set('display', $displays);
$view->save();
$sandbox['converted']++;
}
$sandbox['current']++;
$sandbox['#finished'] = $sandbox['current'] / $sandbox['total'];
}
}
if ($sandbox['#finished'] >= 1) {
if ($sandbox['converted']) {
return t('@count view configs converted.', ['@count' => $sandbox['converted']]);
}
else {
return t('No conversions were required by Views Bulk Operations.');
}
}
}
services:
views_bulk_operations.data:
class: Drupal\views_bulk_operations\Service\ViewsBulkOperationsViewData
arguments: ['@event_dispatcher']
arguments: ['@event_dispatcher', '@pager.manager']
views_bulk_operations.processor:
class: Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor
arguments: ['@views_bulk_operations.data', '@plugin.manager.views_bulk_operations_action', '@current_user', '@module_handler']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment