|
157 | 157 | use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
158 | 158 | use Symfony\Component\Serializer\Normalizer\ProblemNormalizer;
|
159 | 159 | use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;
|
| 160 | +use Symfony\Component\Serializer\Serializer; |
160 | 161 | use Symfony\Component\Serializer\SerializerAwareInterface;
|
161 | 162 | use Symfony\Component\Stopwatch\Stopwatch;
|
162 | 163 | use Symfony\Component\String\LazyString;
|
@@ -357,11 +358,19 @@ public function load(array $configs, ContainerBuilder $container)
|
357 | 358 | $container->getDefinition('exception_listener')->replaceArgument(3, $config['exceptions']);
|
358 | 359 |
|
359 | 360 | if ($this->readConfigEnabled('serializer', $container, $config['serializer'])) {
|
360 |
| - if (!class_exists(\Symfony\Component\Serializer\Serializer::class)) { |
| 361 | + if (!class_exists(Serializer::class)) { |
361 | 362 | throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
|
362 | 363 | }
|
363 | 364 |
|
364 | 365 | $this->registerSerializerConfiguration($config['serializer'], $container, $loader);
|
| 366 | + } else { |
| 367 | + $container->register('.argument_resolver.request_payload.no_serializer', Serializer::class) |
| 368 | + ->addError('You can neither use "#[MapRequestPayload]" nor "#[MapQueryString]" since the Serializer component is not ' |
| 369 | + .(class_exists(Serializer::class) ? 'enabled. Try setting "framework.serializer" to true.' : 'installed. Try running "composer require symfony/serializer-pack".') |
| 370 | + ); |
| 371 | + |
| 372 | + $container->getDefinition('argument_resolver.request_payload') |
| 373 | + ->replaceArgument(0, new Reference('.argument_resolver.request_payload.no_serializer', ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE)); |
365 | 374 | }
|
366 | 375 |
|
367 | 376 | if ($propertyInfoEnabled) {
|
|
0 commit comments