1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace App\Serializer; |
||
6 | |||
7 | use App\Entity\Attachment; |
||
8 | use App\Serializer\Processor\FileHrefProcessor; |
||
9 | use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
||
10 | use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; |
||
11 | |||
12 | class AttachmentNormalizer implements NormalizerInterface |
||
13 | { |
||
14 | private $normalizer; |
||
15 | private $fileHrefProcessor; |
||
16 | |||
17 | public function __construct( |
||
18 | ObjectNormalizer $normalizer, |
||
19 | FileHrefProcessor $fileHrefProcessor |
||
20 | ) { |
||
21 | $this->normalizer = $normalizer; |
||
22 | $this->fileHrefProcessor = $fileHrefProcessor; |
||
23 | } |
||
24 | |||
25 | public function normalize($object, $format = null, array $context = []) |
||
26 | { |
||
27 | $data = $this->normalizer->normalize($object, $format, $context); |
||
28 | $data = $this->fileHrefProcessor->process($object, $data); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
29 | |||
30 | return $data; |
||
31 | } |
||
32 | |||
33 | public function supportsNormalization($data, $format = null): bool |
||
34 | { |
||
35 | return $data instanceof Attachment; |
||
36 | } |
||
37 | } |
||
38 |