From 26e0b9032023f706e0ca4cf1cc00e049466a2673 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 9 Apr 2024 12:01:28 -0300 Subject: [PATCH] Add in the fix to the old processor. --- src/Plugin/search_api/processor/EmbargoProcessor.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Plugin/search_api/processor/EmbargoProcessor.php b/src/Plugin/search_api/processor/EmbargoProcessor.php index ca00306..c20edf9 100644 --- a/src/Plugin/search_api/processor/EmbargoProcessor.php +++ b/src/Plugin/search_api/processor/EmbargoProcessor.php @@ -137,8 +137,17 @@ public function addFieldValues(ItemInterface $item) : void { /** @var \Drupal\embargo\EmbargoStorageInterface $embargo_storage */ $embargo_storage = $this->entityTypeManager->getStorage('embargo'); $embargoes = $embargo_storage->getApplicableEmbargoes($entity); + $relevant_embargoes = array_filter( + $embargoes, + function (EmbargoInterface $embargo) use ($entity) { + return in_array($embargo->getEmbargoType(), match ($entity->getEntityTypeId()) { + 'file', 'media' => [EmbargoInterface::EMBARGO_TYPE_FILE, EmbargoInterface::EMBARGO_TYPE_NODE], + 'node' => [EmbargoInterface::EMBARGO_TYPE_NODE], + }); + } + ); - foreach ($embargoes as $embargo) { + foreach ($relevant_embargoes as $embargo) { $this->getFieldsHelper()->extractFields($embargo->getTypedData(), $to_extract); }