Skip to content

Commit

Permalink
Merge pull request #862 from Islandora/jsonld-cache-tags
Browse files Browse the repository at this point in the history
Add check for cache tags in JSON-LD alter hook.
  • Loading branch information
jordandukart authored Mar 25, 2022
2 parents 081183b + 4c08d5a commit 6d752e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"islandora/jsonld": "^2",
"stomp-php/stomp-php": "4.*",
"drupal/jwt": "^1.0.0-beta5",
"drupal/filehash": "^1.1",
"drupal/filehash": "^1.1 || ^2",
"drupal/prepopulate" : "^2.2",
"drupal/eva" : "^2.0",
"drupal/features" : "^3.7",
Expand All @@ -39,7 +39,7 @@
"suggest": {
"drupal/transliterate_filenames": "Sanitizes filenames when they are uploaded so they don't break your repository."
},
"license": "GPL-2.0+",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Islandora Foundation",
Expand Down
5 changes: 3 additions & 2 deletions islandora.module
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use Drupal\media\MediaInterface;
use Drupal\file\FileInterface;
use Drupal\taxonomy\TermInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\serialization\Normalizer\CacheableNormalizerInterface;

/**
* Implements hook_help().
Expand Down Expand Up @@ -251,8 +252,8 @@ function islandora_jsonld_alter_normalized_array(EntityInterface $entity, array
$reaction->execute($entity, $normalized, $context);
foreach ($context_manager->getActiveContexts() as $context_config) {
try {
if ($context_config->getReaction($reaction->getPluginId())) {
$context['cacheability']->addCacheTags($context_config->getCacheTags());
if ($context_config->getReaction($reaction->getPluginId()) && isset($context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY])) {
$context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY]->addCacheableDependency($context_config);
};
}
catch (PluginNotFoundException $e) {
Expand Down

0 comments on commit 6d752e4

Please sign in to comment.