Skip to content

Commit

Permalink
move xml load logic to describers
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Jan 2, 2024
1 parent 1ecb9a0 commit 035db3f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
12 changes: 2 additions & 10 deletions DependencyInjection/NelmioApiDocExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Routing\RouteCollection;

Expand Down Expand Up @@ -174,13 +171,8 @@ public function load(array $configs, ContainerBuilder $container): void
->setArgument(1, $config['media_types']);
}

if (
PHP_VERSION_ID > 80100
&& class_exists(MapRequestPayload::class)
&& class_exists(MapQueryParameter::class)
&& class_exists(MapQueryString::class)
) {
$loader->load('symfony.xml');
if (PHP_VERSION_ID > 80100) {
$loader->load('inline_parameter.xml');

// Add autoconfiguration for inline parameter describer
$container->registerForAutoconfiguration(InlineParameterDescriberInterface::class)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ final class SymfonyMapQueryParameterDescriber implements InlineParameterDescribe

public function supports(ArgumentMetadata $argumentMetadata): bool
{
if (!class_exists(MapQueryParameter::class)) {
return false;
}

if (!$argumentMetadata->getAttributes(MapQueryParameter::class, ArgumentMetadata::IS_INSTANCEOF)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public function __construct(

public function supports(ArgumentMetadata $argumentMetadata): bool
{
if (!class_exists(MapQueryString::class)) {
return false;
}

if (!$argumentMetadata->getAttributes(MapQueryString::class, ArgumentMetadata::IS_INSTANCEOF)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ final class SymfonyMapRequestPayloadDescriber implements InlineParameterDescribe
{
public function supports(ArgumentMetadata $argumentMetadata): bool
{
if (!class_exists(MapRequestPayload::class)) {
return false;
}

if (!$argumentMetadata->getAttributes(MapRequestPayload::class, ArgumentMetadata::IS_INSTANCEOF)) {
return false;
}
Expand Down

0 comments on commit 035db3f

Please sign in to comment.