Skip to content

Commit bb53789

Browse files
Fix flatten exception normalizer
1 parent 1a80394 commit bb53789

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Serializer/Normalizer/FlattenExceptionNormalizer.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ public function normalize($exception, $format = null, array $context = [])
7676

7777
public function supportsNormalization($data, $format = null, array $context = [])
7878
{
79-
return $data instanceof FlattenException && ($context[Serializer::FOS_BUNDLE_SERIALIZATION_CONTEXT] ?? false);
79+
if (!($data instanceof FlattenException)) {
80+
return false;
81+
}
82+
83+
// we are in fos rest context
84+
if (!empty($context[Serializer::FOS_BUNDLE_SERIALIZATION_CONTEXT])) {
85+
return true;
86+
}
87+
88+
// we are in messenger context
89+
if (!empty($context[Serializer::MESSENGER_SERIALIZATION_CONTEXT])) {
90+
return false;
91+
}
92+
93+
return true;
8094
}
8195
}

0 commit comments

Comments
 (0)