Browse Source

Merge pull request #862 from Islandora/jsonld-cache-tags

Add check for cache tags in JSON-LD alter hook.
pull/866/head
Jordan Dukart 3 years ago committed by GitHub
parent
commit
6d752e479e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      composer.json
  2. 5
      islandora.module

4
composer.json

@ -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",
@ -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",

5
islandora.module

@ -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().
@ -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) {

Loading…
Cancel
Save