Last active
February 25, 2022 08:45
-
-
Save sanslan/f418550c7637ee84f61af9335f7d90ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class APINormalizer implements NormalizerInterface | |
{ | |
public function normalize($exception, string $format = null, array $context = []) | |
{ | |
if($exception instanceof NotFoundHttpException){ | |
return [ | |
'exception'=> [ | |
'message' => $exception->getMessage(), | |
'code' => $exception->getStatusCode(), | |
], | |
]; | |
} | |
return [ | |
'content' => 'This is my custom problem normalizer.', | |
'exception'=> [ | |
'message' => $exception->getMessage(), | |
'code' => $exception->getStatusCode(), | |
], | |
]; | |
} | |
public function supportsNormalization($data, string $format = null) | |
{ | |
return $data instanceof FlattenException; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment