Skip to content

Commit

Permalink
Fix flatten exception normalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Nov 1, 2021
1 parent 1a80394 commit bb53789
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Serializer/Normalizer/FlattenExceptionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ public function normalize($exception, $format = null, array $context = [])

public function supportsNormalization($data, $format = null, array $context = [])
{
return $data instanceof FlattenException && ($context[Serializer::FOS_BUNDLE_SERIALIZATION_CONTEXT] ?? false);
if (!($data instanceof FlattenException)) {
return false;
}

// we are in fos rest context
if (!empty($context[Serializer::FOS_BUNDLE_SERIALIZATION_CONTEXT])) {
return true;
}

// we are in messenger context
if (!empty($context[Serializer::MESSENGER_SERIALIZATION_CONTEXT])) {
return false;
}

return true;
}
}

0 comments on commit bb53789

Please sign in to comment.