Commit 9d073650 authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3270028 by RenatoG: Change the if conditionals to use switch statement

parent e061ab0e
Loading
Loading
Loading
Loading
+54 −59
Original line number Diff line number Diff line
@@ -111,8 +111,9 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {

    foreach ($blocks as $block) {

      // If is insert include this class to all blocks.
      if ($this->operation == 'insert') {
      switch ($this->operation) {

        case 'insert':

          // Get the current block classes configured.
          $current_classes = $block->getThirdPartySetting('block_class', 'classes');
@@ -132,10 +133,7 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
          // Go to the next iteration.
          continue;

      }

      // If is insert include this attribute to all blocks.
      if ($this->operation == 'insert_attributes') {
        case 'insert_attributes':

          // Get the current block attributes configured.
          $current_attributes = $block->getThirdPartySetting('block_class', 'attributes');
@@ -155,17 +153,14 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
          // Go to the next iteration.
          continue;

      }

      // If is update get all values to update.
      if ($this->operation == 'update') {
        case 'update':

          // 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)) {
          return;
            continue;
          }

          // Update the new block classes value with this replace.
@@ -180,9 +175,7 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
          // Go to the next iteration.
          continue;

      }

      if ($this->operation == 'delete') {
        case 'delete':

          // If there is ThirdPartySetting remove that.
          $block->unsetThirdPartySetting('block_class', 'classes');
@@ -190,9 +183,9 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
          // Block save.
          $block->save();

      }
          continue;

      if ($this->operation == 'delete_attributes') {
        case 'delete_attributes':

          // If there is ThirdPartySetting remove that.
          $block->unsetThirdPartySetting('block_class', 'attributes');
@@ -200,6 +193,8 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
          // Block save.
          $block->save();

          continue;

      }
    }