Skip to content

Commit

Permalink
Merge pull request #13 from discoverygarden/DDST-54
Browse files Browse the repository at this point in the history
[DDST-54] add node_list and media_list cache tags
  • Loading branch information
nchiasson-dgi authored Apr 25, 2024
2 parents e4b52ef + 780b0f0 commit 1af6951
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\EntityReferenceFieldItemList;
use Drupal\iiif_presentation_api\MappedFieldInterface;
use Drupal\iiif_presentation_api\Normalizer\V3\NormalizerBase;
use Drupal\islandora_iiif_presentation_api\Normalizer\FieldItemListSpecificNormalizerTrait;
use Drupal\iiif_presentation_api\MappedFieldInterface;

/**
* Expands entity reference fields to their referenced entity given constraints.
Expand Down
2 changes: 1 addition & 1 deletion src/Normalizer/V3/ImageItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
use Drupal\Core\Url;
use Drupal\file\FileInterface;
use Drupal\iiif_presentation_api\Event\V3\ImageBodyEvent;
use Drupal\iiif_presentation_api\MappedFieldInterface;
use Drupal\iiif_presentation_api\Normalizer\EntityUriTrait;
use Drupal\iiif_presentation_api\Normalizer\V3\NormalizerBase;
use Drupal\image\Plugin\Field\FieldType\ImageItem;
use Drupal\islandora_iiif_presentation_api\Normalizer\FieldItemSpecificNormalizerTrait;
use Drupal\iiif_presentation_api\MappedFieldInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Serializer\Exception\LogicException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\islandora_iiif_presentation_api\Normalizer\V3;

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\islandora\IslandoraUtils;

/**
Expand All @@ -27,6 +28,8 @@ public function normalize($object, $format = NULL, array $context = []) {
->sort('field_weight')
->execute();

$this->addCacheableDependency($context, (new CacheableMetadata())->addCacheTags(['node_list']));

// Load all the entities.
$children = $this->entityTypeManager->getStorage('node')->loadMultiple($ids);
if (!empty($children)) {
Expand Down
4 changes: 3 additions & 1 deletion src/Normalizer/V3/ModelEntityReferenceItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Drupal\islandora_iiif_presentation_api\Normalizer\V3;

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
use Drupal\iiif_presentation_api\MappedFieldInterface;
use Drupal\iiif_presentation_api\Normalizer\V3\NormalizerBase;
use Drupal\islandora\IslandoraUtils;
use Drupal\islandora_iiif_presentation_api\Normalizer\FieldItemSpecificNormalizerTrait;
use Drupal\iiif_presentation_api\MappedFieldInterface;
use Drupal\taxonomy\TermInterface;
use Symfony\Component\Serializer\Exception\LogicException;

Expand Down Expand Up @@ -52,6 +53,7 @@ public function __construct(IslandoraUtils $islandora_utils) {
* {@inheritDoc}
*/
public function normalize($object, $format = NULL, array $context = []) {
$this->addCacheableDependency($context, (new CacheableMetadata())->addCacheTags(['media_list']));
// XXX: In its current form this is only going to be applicable to things
// that have image media as their service files.
if ($media = $this->getDerivativeMedia($object)) {
Expand Down

0 comments on commit 1af6951

Please sign in to comment.