Loading src/Form/BlockClassConfirmBulkOperationForm.php +102 −62 Original line number Diff line number Diff line Loading @@ -115,6 +115,58 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { case 'insert': $this->insertOperation($block); continue 2; case 'insert_attributes': $this->insertAttributes($block); continue 2; case 'update': $this->updateOperation($block); continue 2; case 'delete': $this->deleteOperation($block); continue 2; case 'delete_attributes': $this->deleteAttributes($block); continue 2; } } // Clear the session because the confirmation is done. \Drupal::service('session')->remove('block_class_confirm_bulk_operation'); \Drupal::messenger()->addStatus($this->t('Bulk operation concluded')); // Get path bulk operation. $bulk_operation_path = Url::fromRoute('block_class.bulk_operations')->toString(); // Get response. $response = new RedirectResponse($bulk_operation_path); // Send to confirmation. $response->send(); exit; } /** * Method to do the Insert Operation. */ public function insertOperation(&$block) { // Get the current block classes configured. $current_classes = $block->getThirdPartySetting('block_class', 'classes'); Loading @@ -129,11 +181,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Save the block. $block->save(); } // Go to the next iteration. continue; case 'insert_attributes': /** * Method to do the Insert Attributes. */ public function insertAttributes(&$block) { // Get the current block attributes configured. $current_attributes = $block->getThirdPartySetting('block_class', 'attributes'); Loading @@ -149,18 +202,19 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Save the block. $block->save(); } // Go to the next iteration. continue; case 'update': /** * Method to do the Update Operation. */ public function updateOperation(&$block) { // Get the current block classes configured. $current_block_classes = $block->getThirdPartySetting('block_class', 'classes'); // If the current block class doesn't have this current class, skip. if (!preg_match("/\b" . $this->currentClass . "\b/i", $current_block_classes)) { continue; return FALSE; } // Update the new block classes value with this replace. Loading @@ -172,10 +226,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Save the block. $block->save(); // Go to the next iteration. continue; } case 'delete': /** * Method to do the delete Operation. */ public function deleteOperation(&$block) { // If there is ThirdPartySetting remove that. $block->unsetThirdPartySetting('block_class', 'classes'); Loading @@ -183,9 +239,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Block save. $block->save(); continue; } case 'delete_attributes': /** * Method to do the delete attributes. */ public function deleteAttributes(&$block) { // If there is ThirdPartySetting remove that. $block->unsetThirdPartySetting('block_class', 'attributes'); Loading @@ -193,25 +252,6 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Block save. $block->save(); continue; } } // Clear the session because the confirmation is done. \Drupal::service('session')->remove('block_class_confirm_bulk_operation'); \Drupal::messenger()->addStatus($this->t('Bulk operation concluded')); // Get path bulk operation. $bulk_operation_path = Url::fromRoute('block_class.bulk_operations')->toString(); // Get response. $response = new RedirectResponse($bulk_operation_path); // Send to confirmation. $response->send(); exit; } /** Loading Loading
src/Form/BlockClassConfirmBulkOperationForm.php +102 −62 Original line number Diff line number Diff line Loading @@ -115,6 +115,58 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { case 'insert': $this->insertOperation($block); continue 2; case 'insert_attributes': $this->insertAttributes($block); continue 2; case 'update': $this->updateOperation($block); continue 2; case 'delete': $this->deleteOperation($block); continue 2; case 'delete_attributes': $this->deleteAttributes($block); continue 2; } } // Clear the session because the confirmation is done. \Drupal::service('session')->remove('block_class_confirm_bulk_operation'); \Drupal::messenger()->addStatus($this->t('Bulk operation concluded')); // Get path bulk operation. $bulk_operation_path = Url::fromRoute('block_class.bulk_operations')->toString(); // Get response. $response = new RedirectResponse($bulk_operation_path); // Send to confirmation. $response->send(); exit; } /** * Method to do the Insert Operation. */ public function insertOperation(&$block) { // Get the current block classes configured. $current_classes = $block->getThirdPartySetting('block_class', 'classes'); Loading @@ -129,11 +181,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Save the block. $block->save(); } // Go to the next iteration. continue; case 'insert_attributes': /** * Method to do the Insert Attributes. */ public function insertAttributes(&$block) { // Get the current block attributes configured. $current_attributes = $block->getThirdPartySetting('block_class', 'attributes'); Loading @@ -149,18 +202,19 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Save the block. $block->save(); } // Go to the next iteration. continue; case 'update': /** * Method to do the Update Operation. */ public function updateOperation(&$block) { // Get the current block classes configured. $current_block_classes = $block->getThirdPartySetting('block_class', 'classes'); // If the current block class doesn't have this current class, skip. if (!preg_match("/\b" . $this->currentClass . "\b/i", $current_block_classes)) { continue; return FALSE; } // Update the new block classes value with this replace. Loading @@ -172,10 +226,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Save the block. $block->save(); // Go to the next iteration. continue; } case 'delete': /** * Method to do the delete Operation. */ public function deleteOperation(&$block) { // If there is ThirdPartySetting remove that. $block->unsetThirdPartySetting('block_class', 'classes'); Loading @@ -183,9 +239,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Block save. $block->save(); continue; } case 'delete_attributes': /** * Method to do the delete attributes. */ public function deleteAttributes(&$block) { // If there is ThirdPartySetting remove that. $block->unsetThirdPartySetting('block_class', 'attributes'); Loading @@ -193,25 +252,6 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase { // Block save. $block->save(); continue; } } // Clear the session because the confirmation is done. \Drupal::service('session')->remove('block_class_confirm_bulk_operation'); \Drupal::messenger()->addStatus($this->t('Bulk operation concluded')); // Get path bulk operation. $bulk_operation_path = Url::fromRoute('block_class.bulk_operations')->toString(); // Get response. $response = new RedirectResponse($bulk_operation_path); // Send to confirmation. $response->send(); exit; } /** Loading