Skip to content

Commit ed3629d

Browse files
committed
Revert "test defaults parameters"
This reverts commit e6cea1f.
1 parent 0decc64 commit ed3629d

2 files changed

Lines changed: 0 additions & 244 deletions

File tree

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
use ApiPlatform\Metadata\McpTool;
4848
use ApiPlatform\Metadata\NotExposed;
4949
use ApiPlatform\Metadata\OperationMutatorInterface;
50-
use ApiPlatform\Metadata\Parameter;
51-
use ApiPlatform\Metadata\Parameters;
5250
use ApiPlatform\Metadata\Patch;
5351
use ApiPlatform\Metadata\Post;
5452
use ApiPlatform\Metadata\Put;
@@ -441,66 +439,9 @@ private function normalizeDefaults(array $defaults): array
441439
$normalizedDefaults['extra_properties'][$option] = $value;
442440
}
443441

444-
if (isset($normalizedDefaults['parameters']) && \is_array($normalizedDefaults['parameters'])) {
445-
$normalizedDefaults['parameters'] = $this->normalizeParametersConfig($normalizedDefaults['parameters']);
446-
}
447-
448442
return $normalizedDefaults;
449443
}
450444

451-
private function normalizeParametersConfig(array $parametersConfig): Parameters|array
452-
{
453-
$parameters = [];
454-
$hasClassNames = false;
455-
456-
foreach ($parametersConfig as $key => $config) {
457-
if (class_exists($key) && is_subclass_of($key, Parameter::class)) {
458-
$hasClassNames = true;
459-
$parameterClass = $key;
460-
$parameterConfig = \is_array($config) ? $config : [];
461-
462-
try {
463-
$reflection = new \ReflectionClass($parameterClass);
464-
$constructor = $reflection->getConstructor();
465-
466-
if (null === $constructor) {
467-
continue;
468-
}
469-
470-
$args = [];
471-
foreach ($constructor->getParameters() as $param) {
472-
$paramName = $param->getName();
473-
if (isset($parameterConfig[$paramName])) {
474-
$args[$paramName] = $parameterConfig[$paramName];
475-
} elseif ($param->isDefaultValueAvailable()) {
476-
$args[$paramName] = $param->getDefaultValue();
477-
}
478-
}
479-
480-
$instance = $reflection->newInstance(...$args);
481-
482-
if (null !== $instance->getKey()) {
483-
$parameters[$instance->getKey()] = $instance;
484-
}
485-
} catch (\ReflectionException|\TypeError $e) {
486-
continue;
487-
}
488-
} else {
489-
$parameters[$key] = $config;
490-
}
491-
}
492-
493-
if ($hasClassNames || !empty($parameters)) {
494-
try {
495-
return new Parameters($parameters);
496-
} catch (\Throwable $e) {
497-
return $parameters;
498-
}
499-
}
500-
501-
return $parameters;
502-
}
503-
504445
private function registerMetadataConfiguration(ContainerBuilder $container, array $config, PhpFileLoader $loader): void
505446
{
506447
[$xmlResources, $yamlResources, $phpResources] = $this->getResourcesToWatch($container, $config);

src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionParameterClassNameTest.php

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
 (0)