Skip to content

Commit

Permalink
Merge f07714f into aaeb706
Browse files Browse the repository at this point in the history
  • Loading branch information
tuutti authored Aug 31, 2023
2 parents aaeb706 + f07714f commit f0d1bde
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"conflict": {
"drupal/core-recommended": "<9.5",
"drupal/ctools": "<3.11 || ^4.0.1",
"drupal/helfi_api_base": "<2.4.10",
"drupal/helfi_media_map": "*",
"drush/drush": "<11"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ field_mapper_config:
value: '$.attributes["field_announcement_link"]["uri"]'
storage_client_id: helfi_announcements
storage_client_config: { }
persistent_cache_max_age: 600
persistent_cache_max_age: -1
annotation_entity_type_id: null
annotation_bundle_id: null
annotation_field_name: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ function _helfi_global_announcement_create_block() : void {
function helfi_global_announcement_update_9001() : void {
helfi_global_announcement_grant_permissions();
}

/**
* Re-install configuration to update cache lifetime.
*/
function helfi_global_announcement_update_9002() : void {
\Drupal::service('helfi_platform_config.config_update_helper')
->update('helfi_global_announcement');
}
21 changes: 0 additions & 21 deletions modules/helfi_global_announcement/helfi_global_announcement.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

declare(strict_types = 1);

use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\entity\BundleFieldDefinition;
use Drupal\helfi_global_announcement\Plugin\ExternalEntities\StorageClient\Announcements;

/**
* Gets the block configurations.
Expand Down Expand Up @@ -93,22 +91,3 @@ function helfi_global_announcement_entity_bundle_field_info_alter(
}
}
}

/**
* Implements hook_cron().
*/
function helfi_global_announcement_cron(): void {
$store = \Drupal::service('tempstore.shared')->get('global_announcement');
$globalEntityStorage = \Drupal::entityTypeManager()
->getStorage('helfi_announcements');

$externalAnnouncements = $globalEntityStorage
->loadMultiple();

$newHash = hash('sha256', serialize($externalAnnouncements));
$hash = $store->get('announcements');
if ($hash !== $newHash) {
$store->set('announcements', $newHash);
Cache::invalidateTags([Announcements::$customCacheTag]);
}
}

0 comments on commit f0d1bde

Please sign in to comment.