function content_lock_update_8002 in Content locking (anti-concurrent editing) 8
Same name and namespace in other branches
- 8.2 content_lock.install \content_lock_update_8002()
Use boolean instead of content_lock_field views field plugin.
File
- ./
content_lock.install, line 87 - Create content_lock table.
Code
function content_lock_update_8002(&$sandbox) {
$config_factory = \Drupal::configFactory();
// Find all views configs.
foreach ($config_factory
->listAll('views.view.') as $view_config_name) {
$view = $config_factory
->getEditable($view_config_name);
// Go through each display on each view.
$displays = $view
->get('display');
foreach ($displays as $display_name => $display) {
// Go through all the entity fields on each display and find ones
// currently using 'date' as the plugin.
if (!empty($display['display_options']['fields'])) {
foreach ($display['display_options']['fields'] as $field_name => $field) {
if ($field['field'] === 'is_locked' && $field['plugin_id'] === 'content_lock_field') {
// Update the field to use the new plugin.
$base = "display.{$display_name}.display_options.fields.{$field_name}";
$view
->set($base . '.plugin_id', 'boolean');
}
}
}
}
$view
->save(TRUE);
}
}