Commit 09e69595 authored by Neslee Canil Pinto's avatar Neslee Canil Pinto Committed by Neslee Canil Pinto
Browse files

Issue #3284869 by Neslee Canil Pinto: Integrate presave for block classes...

Issue #3284869 by Neslee Canil Pinto: Integrate presave for block classes inside blockClassesPreSave function
parent f1296a43
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ function block_classes_help($route_name, RouteMatchInterface $route_match) {
/**
 * Implements hook_ENTITY_TYPE_presave().
 */
function block_class_block_presave(BlockInterface $entity) {
function block_classes_block_presave(BlockInterface $entity) {
  // Call the helper class to implement the presave logic.
  \Drupal::service('block_class.helper')->blockClassPreSave($entity);
  \Drupal::service('block_classes.helper')->blockClassesPreSave($entity);
}

/**
+15 −0
Original line number Diff line number Diff line
@@ -123,4 +123,19 @@ class BlockClassesHelperService {
    $this->blockEntity = $this->entityTypeManager->getStorage('block');
  }

  /**
   * Method to do the presave block.
   */
  public function blockClassesPreSave(&$entity) {
    if (empty($entity->getThirdPartySetting('block_classes', 'title_class'))) {
      $entity->unsetThirdPartySetting('block_classes', 'title_class');
    }
    if (empty($entity->getThirdPartySetting('block_classes', 'content_class'))) {
      $entity->unsetThirdPartySetting('block_classes', 'content_class');
    }
    if (empty($entity->getThirdPartySetting('block_classes', 'block_class'))) {
      $entity->unsetThirdPartySetting('block_classes', 'block_class');
    }
  }

}