| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\Serializer\Context\Normalizer; |
| 13 |
|
| 14 |
use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException; |
| 15 |
use Symfony\Component\PropertyAccess\PropertyPath; |
| 16 |
use Symfony\Component\Serializer\Context\ContextBuilderInterface; |
| 17 |
use Symfony\Component\Serializer\Context\ContextBuilderTrait; |
| 18 |
use Symfony\Component\Serializer\Exception\InvalidArgumentException; |
| 19 |
use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
final class UnwrappingDenormalizerContextBuilder implements ContextBuilderInterface |
| 27 |
{ |
| 28 |
use ContextBuilderTrait; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public function withUnwrapPath(?string $unwrapPath): static |
| 40 |
{ |
| 41 |
if (null === $unwrapPath) { |
| 42 |
return $this->with(UnwrappingDenormalizer::UNWRAP_PATH, null); |
| 43 |
} |
| 44 |
|
| 45 |
try { |
| 46 |
new PropertyPath($unwrapPath); |
| 47 |
} catch (InvalidPropertyPathException $e) { |
| 48 |
throw new InvalidArgumentException(\sprintf('The "%s" property path is not valid.', $unwrapPath), previous: $e); |
| 49 |
} |
| 50 |
|
| 51 |
return $this->with(UnwrappingDenormalizer::UNWRAP_PATH, $unwrapPath); |
| 52 |
} |
| 53 |
} |