Skip to content
Snippets Groups Projects
Commit 11b092b6 authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3275884 by RenatoG: Implement the bulk operation to remove all custom id replaced on blocks

parent 4fa16563
No related branches found
No related tags found
10 merge requests!62Issue #3272848 by RenatoG: When the error appear the field is hidden and the...,!59Issue #3497768: Click JavaScript to close details causes modals to scroll unnecessarily,!35Issue #3366420: \Drupal calls should be avoided in classes,!34Issue #3366420: \Drupal calls should be avoided in classes,!29Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!28Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!23Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!22Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!20Issue #3272632 by RenatoG: Add a logic to block and disable the remove item if...,!7Issue #3320529 by justcaldwell: block_classes_stored setting only retains classes from most recently saved block
......@@ -134,6 +134,12 @@ class BlockClassBulkOperationsForm extends ConfigFormBase {
$operation_options['delete_attributes'] = $this->t('Delete all attributes');
}
$enable_attributes = $config->get('enable_id_replacement', FALSE);
if (!empty($enable_attributes)) {
$operation_options['remove_all_custom_ids'] = $this->t("Remove all custom ids (will revert to block's original id)");
}
$form['operation'] = [
'#title' => $this->t("Operation"),
'#type' => 'select',
......
......@@ -213,6 +213,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
continue 2;
case 'remove_all_custom_ids':
$this->removeAllCustomIds($block);
continue 2;
}
}
......@@ -439,6 +445,36 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
}
/**
* Method to do remove all custom ids.
*/
public function removeAllCustomIds(&$block) {
// If there is no replaced id, skip.
if (!empty($block->getThirdPartySetting('block_class', 'replaced_id'))) {
return FALSE;
}
$bid = $block->id();
$block = Block::load($bid);
$block->unsetThirdPartySetting('block_class', 'replaced_id');
// Block save.
$block->save();
// Get the config object.
$config = $this->configFactory->getEditable('block_class.settings');
// Remove from settings.
$config->set('id_replacement_stored', FALSE);
// Save.
$config->save();
}
/**
* Method to do the delete attributes.
*/
......@@ -561,6 +597,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
$message_to_confirm = $this->t('Do you want to delete all attributes?');
break;
case 'remove_all_custom_ids':
$message_to_confirm = $this->t('Do you want to remove all custom Ids?');
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment