|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Starweb\Api\Generated\Normalizer; |
|
4
|
|
|
|
|
5
|
|
|
use Jane\JsonSchemaRuntime\Reference; |
|
6
|
|
|
use Symfony\Component\Serializer\Exception\InvalidArgumentException; |
|
7
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; |
|
8
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; |
|
9
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; |
|
10
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; |
|
11
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; |
|
12
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
|
13
|
|
|
class ProductModelNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface |
|
14
|
|
|
{ |
|
15
|
|
|
use DenormalizerAwareTrait; |
|
16
|
|
|
use NormalizerAwareTrait; |
|
17
|
|
|
public function supportsDenormalization($data, $type, $format = null) |
|
18
|
|
|
{ |
|
19
|
|
|
return $type === 'Starweb\\Api\\Generated\\Model\\ProductModel'; |
|
20
|
|
|
} |
|
21
|
|
|
public function supportsNormalization($data, $format = null) |
|
22
|
|
|
{ |
|
23
|
|
|
return $data instanceof \Starweb\Api\Generated\Model\ProductModel; |
|
24
|
|
|
} |
|
25
|
|
|
public function denormalize($data, $class, $format = null, array $context = array()) |
|
26
|
|
|
{ |
|
27
|
|
|
if (!is_object($data)) { |
|
28
|
|
|
throw new InvalidArgumentException(); |
|
29
|
|
|
} |
|
30
|
|
|
$object = new \Starweb\Api\Generated\Model\ProductModel(); |
|
31
|
|
|
if (property_exists($data, 'productId')) { |
|
32
|
|
|
$object->setProductId($data->{'productId'}); |
|
33
|
|
|
} |
|
34
|
|
|
if (property_exists($data, 'createdAt')) { |
|
35
|
|
|
$object->setCreatedAt($data->{'createdAt'}); |
|
36
|
|
|
} |
|
37
|
|
|
if (property_exists($data, 'defaultVatRate')) { |
|
38
|
|
|
$object->setDefaultVatRate($data->{'defaultVatRate'}); |
|
39
|
|
|
} |
|
40
|
|
|
if (property_exists($data, 'visibility')) { |
|
41
|
|
|
$object->setVisibility($data->{'visibility'}); |
|
42
|
|
|
} |
|
43
|
|
|
if (property_exists($data, 'visibilityPricelistIds')) { |
|
44
|
|
|
$values = array(); |
|
45
|
|
|
foreach ($data->{'visibilityPricelistIds'} as $value) { |
|
46
|
|
|
$values[] = $value; |
|
47
|
|
|
} |
|
48
|
|
|
$object->setVisibilityPricelistIds($values); |
|
49
|
|
|
} |
|
50
|
|
|
if (property_exists($data, 'moreInfoUrl')) { |
|
51
|
|
|
$object->setMoreInfoUrl($data->{'moreInfoUrl'}); |
|
52
|
|
|
} |
|
53
|
|
|
if (property_exists($data, 'manufacturerId')) { |
|
54
|
|
|
$object->setManufacturerId($data->{'manufacturerId'}); |
|
55
|
|
|
} |
|
56
|
|
|
if (property_exists($data, 'unitId')) { |
|
57
|
|
|
$object->setUnitId($data->{'unitId'}); |
|
58
|
|
|
} |
|
59
|
|
|
if (property_exists($data, 'sortIndex')) { |
|
60
|
|
|
$object->setSortIndex($data->{'sortIndex'}); |
|
61
|
|
|
} |
|
62
|
|
|
if (property_exists($data, 'type')) { |
|
63
|
|
|
$object->setType($data->{'type'}); |
|
64
|
|
|
} |
|
65
|
|
|
if (property_exists($data, 'isBackInStockWatchable')) { |
|
66
|
|
|
$object->setIsBackInStockWatchable($data->{'isBackInStockWatchable'}); |
|
67
|
|
|
} |
|
68
|
|
|
if (property_exists($data, 'bundleUseManualPrice')) { |
|
69
|
|
|
$object->setBundleUseManualPrice($data->{'bundleUseManualPrice'}); |
|
70
|
|
|
} |
|
71
|
|
|
if (property_exists($data, 'accounting')) { |
|
72
|
|
|
$object->setAccounting($data->{'accounting'}); |
|
73
|
|
|
} |
|
74
|
|
|
if (property_exists($data, 'hasSeveralVariants')) { |
|
75
|
|
|
$object->setHasSeveralVariants($data->{'hasSeveralVariants'}); |
|
76
|
|
|
} |
|
77
|
|
|
if (property_exists($data, 'modifiedAt')) { |
|
78
|
|
|
$object->setModifiedAt($data->{'modifiedAt'}); |
|
79
|
|
|
} |
|
80
|
|
|
if (property_exists($data, 'variants')) { |
|
81
|
|
|
$object->setVariants($this->denormalizer->denormalize($data->{'variants'}, 'Starweb\\Api\\Generated\\Model\\ProductVariantModelCollection', 'json', $context)); |
|
|
|
|
|
|
82
|
|
|
} |
|
83
|
|
|
if (property_exists($data, 'bundledProducts')) { |
|
84
|
|
|
$object->setBundledProducts($this->denormalizer->denormalize($data->{'bundledProducts'}, 'Starweb\\Api\\Generated\\Model\\BundledProductsModelCollection', 'json', $context)); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
if (property_exists($data, 'mediaFiles')) { |
|
87
|
|
|
$object->setMediaFiles($this->denormalizer->denormalize($data->{'mediaFiles'}, 'Starweb\\Api\\Generated\\Model\\ProductMediaFileLinkModelCollection', 'json', $context)); |
|
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
if (property_exists($data, 'languages')) { |
|
90
|
|
|
$object->setLanguages($this->denormalizer->denormalize($data->{'languages'}, 'Starweb\\Api\\Generated\\Model\\ProductModelLanguages', 'json', $context)); |
|
|
|
|
|
|
91
|
|
|
} |
|
92
|
|
|
if (property_exists($data, 'vatRates')) { |
|
93
|
|
|
$object->setVatRates($this->denormalizer->denormalize($data->{'vatRates'}, 'Starweb\\Api\\Generated\\Model\\ProductVatRateModelCollection', 'json', $context)); |
|
|
|
|
|
|
94
|
|
|
} |
|
95
|
|
|
if (property_exists($data, 'categories')) { |
|
96
|
|
|
$object->setCategories($this->denormalizer->denormalize($data->{'categories'}, 'Starweb\\Api\\Generated\\Model\\ProductCategoryLinkModelCollection', 'json', $context)); |
|
|
|
|
|
|
97
|
|
|
} |
|
98
|
|
|
if (property_exists($data, 'unit')) { |
|
99
|
|
|
$object->setUnit($this->denormalizer->denormalize($data->{'unit'}, 'Starweb\\Api\\Generated\\Model\\ProductUnitModelItem', 'json', $context)); |
|
|
|
|
|
|
100
|
|
|
} |
|
101
|
|
|
if (property_exists($data, 'metaData')) { |
|
102
|
|
|
$object->setMetaData($this->denormalizer->denormalize($data->{'metaData'}, 'Starweb\\Api\\Generated\\Model\\ProductMetaDataModelCollection', 'json', $context)); |
|
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
return $object; |
|
105
|
|
|
} |
|
106
|
|
|
public function normalize($object, $format = null, array $context = array()) |
|
107
|
|
|
{ |
|
108
|
|
|
$data = new \stdClass(); |
|
109
|
|
|
if (null !== $object->getProductId()) { |
|
110
|
|
|
$data->{'productId'} = $object->getProductId(); |
|
111
|
|
|
} |
|
112
|
|
|
if (null !== $object->getCreatedAt()) { |
|
113
|
|
|
$data->{'createdAt'} = $object->getCreatedAt(); |
|
114
|
|
|
} |
|
115
|
|
|
if (null !== $object->getDefaultVatRate()) { |
|
116
|
|
|
$data->{'defaultVatRate'} = $object->getDefaultVatRate(); |
|
117
|
|
|
} |
|
118
|
|
|
if (null !== $object->getVisibility()) { |
|
119
|
|
|
$data->{'visibility'} = $object->getVisibility(); |
|
120
|
|
|
} |
|
121
|
|
|
if (null !== $object->getVisibilityPricelistIds()) { |
|
122
|
|
|
$values = array(); |
|
123
|
|
|
foreach ($object->getVisibilityPricelistIds() as $value) { |
|
124
|
|
|
$values[] = $value; |
|
125
|
|
|
} |
|
126
|
|
|
$data->{'visibilityPricelistIds'} = $values; |
|
127
|
|
|
} |
|
128
|
|
|
if (null !== $object->getMoreInfoUrl()) { |
|
129
|
|
|
$data->{'moreInfoUrl'} = $object->getMoreInfoUrl(); |
|
130
|
|
|
} |
|
131
|
|
|
if (null !== $object->getManufacturerId()) { |
|
132
|
|
|
$data->{'manufacturerId'} = $object->getManufacturerId(); |
|
133
|
|
|
} |
|
134
|
|
|
if (null !== $object->getUnitId()) { |
|
135
|
|
|
$data->{'unitId'} = $object->getUnitId(); |
|
136
|
|
|
} |
|
137
|
|
|
if (null !== $object->getSortIndex()) { |
|
138
|
|
|
$data->{'sortIndex'} = $object->getSortIndex(); |
|
139
|
|
|
} |
|
140
|
|
|
if (null !== $object->getType()) { |
|
141
|
|
|
$data->{'type'} = $object->getType(); |
|
142
|
|
|
} |
|
143
|
|
|
if (null !== $object->getIsBackInStockWatchable()) { |
|
144
|
|
|
$data->{'isBackInStockWatchable'} = $object->getIsBackInStockWatchable(); |
|
145
|
|
|
} |
|
146
|
|
|
if (null !== $object->getBundleUseManualPrice()) { |
|
147
|
|
|
$data->{'bundleUseManualPrice'} = $object->getBundleUseManualPrice(); |
|
148
|
|
|
} |
|
149
|
|
|
if (null !== $object->getAccounting()) { |
|
150
|
|
|
$data->{'accounting'} = $object->getAccounting(); |
|
151
|
|
|
} |
|
152
|
|
|
if (null !== $object->getHasSeveralVariants()) { |
|
153
|
|
|
$data->{'hasSeveralVariants'} = $object->getHasSeveralVariants(); |
|
154
|
|
|
} |
|
155
|
|
|
if (null !== $object->getModifiedAt()) { |
|
156
|
|
|
$data->{'modifiedAt'} = $object->getModifiedAt(); |
|
157
|
|
|
} |
|
158
|
|
|
if (null !== $object->getVariants()) { |
|
159
|
|
|
$data->{'variants'} = $this->normalizer->normalize($object->getVariants(), 'json', $context); |
|
160
|
|
|
} |
|
161
|
|
|
if (null !== $object->getBundledProducts()) { |
|
162
|
|
|
$data->{'bundledProducts'} = $this->normalizer->normalize($object->getBundledProducts(), 'json', $context); |
|
163
|
|
|
} |
|
164
|
|
|
if (null !== $object->getMediaFiles()) { |
|
165
|
|
|
$data->{'mediaFiles'} = $this->normalizer->normalize($object->getMediaFiles(), 'json', $context); |
|
166
|
|
|
} |
|
167
|
|
|
if (null !== $object->getLanguages()) { |
|
168
|
|
|
$data->{'languages'} = $this->normalizer->normalize($object->getLanguages(), 'json', $context); |
|
169
|
|
|
} |
|
170
|
|
|
if (null !== $object->getVatRates()) { |
|
171
|
|
|
$data->{'vatRates'} = $this->normalizer->normalize($object->getVatRates(), 'json', $context); |
|
172
|
|
|
} |
|
173
|
|
|
if (null !== $object->getCategories()) { |
|
174
|
|
|
$data->{'categories'} = $this->normalizer->normalize($object->getCategories(), 'json', $context); |
|
175
|
|
|
} |
|
176
|
|
|
if (null !== $object->getUnit()) { |
|
177
|
|
|
$data->{'unit'} = $this->normalizer->normalize($object->getUnit(), 'json', $context); |
|
178
|
|
|
} |
|
179
|
|
|
if (null !== $object->getMetaData()) { |
|
180
|
|
|
$data->{'metaData'} = $this->normalizer->normalize($object->getMetaData(), 'json', $context); |
|
181
|
|
|
} |
|
182
|
|
|
return $data; |
|
183
|
|
|
} |
|
184
|
|
|
} |