From ae5507570c6ba13ba6e9193e31e0e663eb60fcc2 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Wed, 1 Nov 2023 11:58:31 -0300 Subject: [PATCH 1/4] Bump up to D10. --- islandora_citations.info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/islandora_citations.info.yml b/islandora_citations.info.yml index 09de850..47f2714 100644 --- a/islandora_citations.info.yml +++ b/islandora_citations.info.yml @@ -2,7 +2,7 @@ name: Islandora citations type: module description: Provides a service to manage citations. package: Custom -core_version_requirement: ^9 +core_version_requirement: ^10 dependencies: - drupal:field_permissions - drupal:node From 8057df5dfa07dd27024070aab9783cd53c133879 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Wed, 1 Nov 2023 12:05:26 -0300 Subject: [PATCH 2/4] Fix up method signature. --- src/Normalizer/NormalizerBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Normalizer/NormalizerBase.php b/src/Normalizer/NormalizerBase.php index 0e3b9a8..36572d5 100644 --- a/src/Normalizer/NormalizerBase.php +++ b/src/Normalizer/NormalizerBase.php @@ -18,7 +18,7 @@ abstract class NormalizerBase extends SerializationNormalizerBase implements Nor /** * {@inheritdoc} */ - public function supportsNormalization($data, $format = NULL) { + public function supportsNormalization($data, ?string $format = NULL, array $context = []): bool { return $format === static::FORMAT && parent::supportsNormalization($data, $format); } From 2255f109ddf670539cb262e58d52fe91a3f1e493 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Wed, 1 Nov 2023 12:05:38 -0300 Subject: [PATCH 3/4] Fix up some misc possibly undefined array vars. --- src/Controller/IslandoraCitationsController.php | 2 ++ src/Normalizer/DateTimeNormalizer.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Controller/IslandoraCitationsController.php b/src/Controller/IslandoraCitationsController.php index 47bd7ba..2576628 100644 --- a/src/Controller/IslandoraCitationsController.php +++ b/src/Controller/IslandoraCitationsController.php @@ -50,6 +50,7 @@ public function provideArguments($node_type) { ]; $fields = $this->entityFieldManager->getFieldDefinitions('node', $node_type); + $rows = []; foreach ($fields as $field_definition) { if (!empty($field_definition->getTargetBundle())) { @@ -93,6 +94,7 @@ public function paragraphsArguments($paragraphs_type) { ]; $fields = $this->entityFieldManager->getFieldDefinitions('paragraph', $paragraphs_type->id()); + $rows = []; foreach ($fields as $field_definition) { if (!empty($field_definition->getTargetBundle())) { $data = $field_definition->getThirdPartySetting('islandora_citations', 'csl_field'); diff --git a/src/Normalizer/DateTimeNormalizer.php b/src/Normalizer/DateTimeNormalizer.php index ffc5ed5..1c96e6f 100644 --- a/src/Normalizer/DateTimeNormalizer.php +++ b/src/Normalizer/DateTimeNormalizer.php @@ -57,9 +57,13 @@ public function normalize($datetime, $format = NULL, array $context = []) { assert($datetime instanceof DateTimeInterface); $drupal_date_time = $datetime->getDateTime()->setTimezone($this->getNormalizationTimezone()); if ($drupal_date_time === NULL) { - return $drupal_date_time; + return NULL; } + $date = $this->dateFormatter->format($drupal_date_time->getTimestamp(), 'custom', 'Y-m-d'); + + $element = []; + foreach ($context['csl-map'] as $cslField) { $element[$cslField] = $date; } From f97ab8c556d49fbfb3c9bc5ca6c17273f0a9657d Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Fri, 3 Nov 2023 09:55:09 -0300 Subject: [PATCH 4/4] Pass along the `$context` to the parent call. --- src/Normalizer/NormalizerBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Normalizer/NormalizerBase.php b/src/Normalizer/NormalizerBase.php index 36572d5..42e83d3 100644 --- a/src/Normalizer/NormalizerBase.php +++ b/src/Normalizer/NormalizerBase.php @@ -19,7 +19,7 @@ abstract class NormalizerBase extends SerializationNormalizerBase implements Nor * {@inheritdoc} */ public function supportsNormalization($data, ?string $format = NULL, array $context = []): bool { - return $format === static::FORMAT && parent::supportsNormalization($data, $format); + return $format === static::FORMAT && parent::supportsNormalization($data, $format, $context); } /**