Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/serializer/Normalizer/AbstractNormalizer.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 1fec387a4317 |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
198 * | 198 * |
199 * @param string|object $classOrObject | 199 * @param string|object $classOrObject |
200 * @param array $context | 200 * @param array $context |
201 * @param bool $attributesAsString If false, return an array of {@link AttributeMetadataInterface} | 201 * @param bool $attributesAsString If false, return an array of {@link AttributeMetadataInterface} |
202 * | 202 * |
203 * @throws LogicException if the 'allow_extra_attributes' context variable is false and no class metadata factory is provided | |
204 * | |
203 * @return string[]|AttributeMetadataInterface[]|bool | 205 * @return string[]|AttributeMetadataInterface[]|bool |
204 */ | 206 */ |
205 protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false) | 207 protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false) |
206 { | 208 { |
207 if (!$this->classMetadataFactory) { | 209 if (!$this->classMetadataFactory) { |
210 if (isset($context[static::ALLOW_EXTRA_ATTRIBUTES]) && !$context[static::ALLOW_EXTRA_ATTRIBUTES]) { | |
211 throw new LogicException(sprintf('A class metadata factory must be provided in the constructor when setting "%s" to false.', static::ALLOW_EXTRA_ATTRIBUTES)); | |
212 } | |
213 | |
208 return false; | 214 return false; |
209 } | 215 } |
210 | 216 |
211 $groups = false; | 217 $groups = false; |
212 if (isset($context[static::GROUPS]) && \is_array($context[static::GROUPS])) { | 218 if (isset($context[static::GROUPS]) && \is_array($context[static::GROUPS])) { |
347 | 353 |
348 $params = array_merge($params, $data[$paramName]); | 354 $params = array_merge($params, $data[$paramName]); |
349 } | 355 } |
350 } elseif ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) { | 356 } elseif ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) { |
351 $parameterData = $data[$key]; | 357 $parameterData = $data[$key]; |
358 if (null === $parameterData && $constructorParameter->allowsNull()) { | |
359 $params[] = null; | |
360 // Don't run set for a parameter passed to the constructor | |
361 unset($data[$key]); | |
362 continue; | |
363 } | |
352 try { | 364 try { |
353 if (null !== $constructorParameter->getClass()) { | 365 if (null !== $constructorParameter->getClass()) { |
354 if (!$this->serializer instanceof DenormalizerInterface) { | 366 if (!$this->serializer instanceof DenormalizerInterface) { |
355 throw new LogicException(sprintf('Cannot create an instance of %s from serialized data because the serializer inject in "%s" is not a denormalizer', $constructorParameter->getClass(), static::class)); | 367 throw new LogicException(sprintf('Cannot create an instance of %s from serialized data because the serializer inject in "%s" is not a denormalizer', $constructorParameter->getClass(), static::class)); |
356 } | 368 } |