1 | <?php |
||
15 | class RequestNormalizer extends ObjectNormalizer |
||
16 | { |
||
17 | /** |
||
18 | * RequestNormalizer constructor. |
||
19 | * |
||
20 | * @param ClassMetadataFactoryInterface|null $classMDF |
||
21 | * @param NameConverterInterface|null $nameCv |
||
22 | * @param PropertyAccessorInterface|null $propAs |
||
23 | * @param PropertyTypeExtractorInterface|null $propTE |
||
24 | */ |
||
25 | 5 | public function __construct($classMDF, $nameCv, $propAs, $propTE) |
|
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | 5 | public function supportsNormalization($data, $format = null) |
|
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | 1 | public function normalize($object, $format = null, array $context = []) |
|
42 | { |
||
43 | 1 | if (!$this->serializer instanceof NormalizerInterface) { |
|
44 | throw new LogicException('Cannot normalize attributes because injected serializer is not a normalizer'); |
||
45 | } |
||
46 | /** @var FormRequest $request */ |
||
47 | 1 | $request = &$object; |
|
48 | |||
49 | 1 | return $this->serializer->normalize(new \ArrayObject([ |
|
50 | 1 | 'id' => $request->getId(), |
|
51 | 1 | 'type' => $request->getType(), |
|
52 | 1 | 'status' => $request->getStatus(), |
|
53 | 1 | 'reason' => $request->getReason(), |
|
54 | 1 | 'date' => $request->getDate(), |
|
55 | 1 | 'createdAt' => $request->getCreatedAt(), |
|
56 | 1 | 'updatedAt' => $request->getUpdatedAt(), |
|
57 | 1 | ]), $format, $context); |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
62 | * |
||
63 | * @param mixed $data |
||
64 | * @param string $class |
||
65 | * @param null $format |
||
66 | * @param array $context |
||
67 | * |
||
68 | * @return FormRequest |
||
69 | */ |
||
70 | public function denormalize($data, $class, $format = null, array $context = array()) |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | 1 | public function supportsDenormalization($data, $type, $format = null) |
|
99 | } |
||
100 |