Commit f7ec46dc authored by Michael Caldwell's avatar Michael Caldwell Committed by De Araujo, Renato [CONBR Non-J&J]
Browse files

Issue #3320529 by justcaldwell, RenatoG: block_classes_stored setting only...

Issue #3320529 by justcaldwell, RenatoG: block_classes_stored setting only retains classes from most recently saved block
parent 4d117ac3
Loading
Loading
Loading
Loading
+40 −31
Original line number Diff line number Diff line
@@ -158,7 +158,8 @@ class BlockClassHelperService {
    // Get the block class.
    $block_classes = $entity->getThirdPartySetting('block_class', 'classes');

    $attributes = $entity->getThirdPartySetting('block_class', 'attributes');
    // Only process non-empty values.
    if (!empty($block_classes)) {

      switch ($default_case) {

@@ -200,7 +201,7 @@ class BlockClassHelperService {
      $current_block_classes = array_combine($current_block_classes, $current_block_classes);

      // Merge with the current one.
    $block_classes_to_store = array_merge($current_block_classes, $current_block_classes);
      $block_classes_to_store = array_merge($block_classes_stored, $current_block_classes);

      // Get as JSON.
      $block_classes_to_store = Json::encode($block_classes_to_store);
@@ -208,6 +209,11 @@ class BlockClassHelperService {
      // Store in the config.
      $config->set('block_classes_stored', $block_classes_to_store);

      // Save.
      $config->save();

    }

    // Store the id replacement in the settings only if it is enabled in the
    // Global Settings page.
    if (!empty($config->get('enable_id_replacement'))) {
@@ -249,6 +255,9 @@ class BlockClassHelperService {
      return FALSE;
    }

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

    // Initial value.
    $attribute_keys_stored = '{}';