| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\Serializer\Context\Normalizer; |
| 13 |
|
| 14 |
use Symfony\Component\Serializer\Exception\InvalidArgumentException; |
| 15 |
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
abstract class AbstractObjectNormalizerContextBuilder extends AbstractNormalizerContextBuilder |
| 23 |
{ |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public function withEnableMaxDepth(?bool $enableMaxDepth): static |
| 28 |
{ |
| 29 |
return $this->with(AbstractObjectNormalizer::ENABLE_MAX_DEPTH, $enableMaxDepth); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public function withDepthKeyPattern(?string $depthKeyPattern): static |
| 40 |
{ |
| 41 |
if (null === $depthKeyPattern) { |
| 42 |
return $this->with(AbstractObjectNormalizer::DEPTH_KEY_PATTERN, null); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
$matches = []; |
| 47 |
preg_match_all('/(?<!%)(?:%{2})*%(?<specifier>[a-z])/', $depthKeyPattern, $matches); |
| 48 |
|
| 49 |
if (2 !== \count($matches['specifier']) || 's' !== $matches['specifier'][0] || 's' !== $matches['specifier'][1]) { |
| 50 |
throw new InvalidArgumentException(\sprintf('The depth key pattern "%s" is not valid. You must set exactly two string placeholders.', $depthKeyPattern)); |
| 51 |
} |
| 52 |
|
| 53 |
return $this->with(AbstractObjectNormalizer::DEPTH_KEY_PATTERN, $depthKeyPattern); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public function withDisableTypeEnforcement(?bool $disableTypeEnforcement): static |
| 60 |
{ |
| 61 |
return $this->with(AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT, $disableTypeEnforcement); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public function withSkipNullValues(?bool $skipNullValues): static |
| 68 |
{ |
| 69 |
return $this->with(AbstractObjectNormalizer::SKIP_NULL_VALUES, $skipNullValues); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
public function withSkipUninitializedValues(?bool $skipUninitializedValues): static |
| 76 |
{ |
| 77 |
return $this->with(AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES, $skipUninitializedValues); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public function withMaxDepthHandler(?callable $maxDepthHandler): static |
| 96 |
{ |
| 97 |
return $this->with(AbstractObjectNormalizer::MAX_DEPTH_HANDLER, $maxDepthHandler); |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
public function withExcludeFromCacheKeys(?array $excludeFromCacheKeys): static |
| 107 |
{ |
| 108 |
return $this->with(AbstractObjectNormalizer::EXCLUDE_FROM_CACHE_KEY, $excludeFromCacheKeys); |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
public function withDeepObjectToPopulate(?bool $deepObjectToPopulate): static |
| 119 |
{ |
| 120 |
return $this->with(AbstractObjectNormalizer::DEEP_OBJECT_TO_POPULATE, $deepObjectToPopulate); |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
public function withPreserveEmptyObjects(?bool $preserveEmptyObjects): static |
| 128 |
{ |
| 129 |
return $this->with(AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS, $preserveEmptyObjects); |
| 130 |
} |
| 131 |
} |