Loading block_classes.module +2 −2 Original line number Diff line number Diff line Loading @@ -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); } /** Loading src/Service/BlockClassesHelperService.php +15 −0 Original line number Diff line number Diff line Loading @@ -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'); } } } Loading
block_classes.module +2 −2 Original line number Diff line number Diff line Loading @@ -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); } /** Loading
src/Service/BlockClassesHelperService.php +15 −0 Original line number Diff line number Diff line Loading @@ -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'); } } }