Commit 2f8714fb authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3270453 by RenatoG: Update the operations to include attributes to upper operation

parent 03010787
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ class BlockClassBulkOperationsForm extends ConfigFormBase {
    // Insert the "Insertion attributes" only if attributes is enabled.
    if ($enable_attributes) {
      $operation_options['insert_attributes'] = $this->t('Insert attributes');
      $operation_options['convert_attributes_to_uppercase'] = $this->t('Convert all attributes to uppercase');
      $operation_options['convert_attributes_to_lowercase'] = $this->t('Convert all attributes to lowercase');
    }

+28 −0
Original line number Diff line number Diff line
@@ -141,6 +141,12 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {

          continue 2;

        case 'convert_attributes_to_uppercase':

          $this->convertAttributesToUpperCase($block);

          continue 2;

        case 'convert_attributes_to_lowercase':

          $this->convertAttributesToLowerCase($block);
@@ -262,6 +268,28 @@ class BlockClassConfirmBulkOperationForm extends ConfirmFormBase {
    $block->save();
  }

  /**
   * Method to update attributes to uppercase.
   */
  public function convertAttributesToUpperCase(&$block) {

    // Get the current block classes configured.
    $attributes = $block->getThirdPartySetting('block_class', 'attributes');

    if (empty($attributes)) {
      return FALSE;
    }

    // Add the new attributes in the current ones.
    $attributes = strtoupper($attributes);

    // Store that in the Third Party Setting.
    $block->setThirdPartySetting('block_class', 'attributes', $attributes);

    // Save the block.
    $block->save();
  }

  /**
   * Method to update attributes to lowercase.
   */