Skip to content

Commit

Permalink
Merge pull request #16 from discoverygarden/fix/normalization-scoping
Browse files Browse the repository at this point in the history
[SUP-6256] Only use content sync normalizers for content sync processes
  • Loading branch information
nchiasson-dgi authored Jan 4, 2024
2 parents 5762584 + e6608dd commit 672ae00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Exporter/ContentExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(Serializer $serializer) {
*/
public function exportEntity(ContentEntityInterface $entity, array $context = []) {
$context = $this->context + $context;
// Allows to know to normalizers that this is a content sync generated entity.
// Allows normalizers to know that this is a content sync generated entity.
$context += [
'content_sync' => TRUE,
];
Expand Down
15 changes: 15 additions & 0 deletions src/Normalizer/ContentEntityNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,19 @@ protected function cleanupData(&$data, $entity_type_id, $bundle = FALSE) {
}
}


/**
* @inheritdoc
*/
public function supportsNormalization($data, $format = NULL, array $context = []): bool {
return parent::supportsNormalization($data, $format, $context) && ($context['content_sync'] ?? FALSE);
}

/**
* @inheritdoc
*/
public function supportsDenormalization($data, $type, $format = NULL, array $context = []): bool {
return parent::supportsDenormalization($data, $type, $format, $context);
}

}

0 comments on commit 672ae00

Please sign in to comment.