Skip to content

Commit 6374457

Browse files
committed
Fixing without flag :D
1 parent e27e567 commit 6374457

File tree

8 files changed

+20
-11
lines changed

8 files changed

+20
-11
lines changed

features/json/input_output.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ Feature: JSON DTO input and output
3737
And the response should be in JSON
3838
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
3939
And the JSON node "detail" should be equal to "User does not exist."
40+

src/Core/Metadata/Property/Factory/SerializerPropertyMetadataFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ private function getEffectiveSerializerGroups(array $options, string $resourceCl
168168
return [$groups, $groups];
169169
}
170170

171+
if (\array_key_exists('normalization_groups', $options) && \array_key_exists('denormalization_groups', $options)) {
172+
return [$options['normalization_groups'] ?? null, $options['denormalization_groups'] ?? null];
173+
}
174+
171175
$resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
172176
if (isset($options['collection_operation_name'])) {
173177
$normalizationContext = $resourceMetadata->getCollectionOperationAttribute($options['collection_operation_name'], 'normalization_context', null, true);

src/Doctrine/Orm/State/ItemProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ public function supports(string $resourceClass, array $identifiers = [], ?string
8787

8888
$operation = $context['operation'] ?? $this->resourceMetadataCollectionFactory->create($resourceClass)->getOperation($operationName);
8989

90-
return !($operation->isCollection() ?? false);
90+
return !($operation->getExtraProperties()['is_legacy_subresource'] ?? false) && !($operation->isCollection() ?? false);
9191
}
9292
}

src/GraphQl/Type/FieldsBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
2525
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2626
use ApiPlatform\State\Pagination\Pagination;
27+
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyGroup;
2728
use ApiPlatform\Util\Inflector;
2829
use GraphQL\Type\Definition\InputObjectType;
2930
use GraphQL\Type\Definition\NullableType;

src/Metadata/Property/Factory/LegacyPropertyMetadataFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace ApiPlatform\Metadata\Property\Factory;
1515

16+
use ApiPlatform\Core\Exception\ResourceClassNotFoundException;
1617
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
1718
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface as LegacyPropertyMetadataFactoryInterface;
1819
use ApiPlatform\Core\Annotation\ApiProperty as ApiPropertyAnnotation;
@@ -51,7 +52,7 @@ public function create(string $resourceClass, string $property, array $options =
5152

5253
try {
5354
$legacyPropertyMetadata = $this->legacyPropertyMetadataFactory->create($resourceClass, $property, $options);
54-
} catch (PropertyNotFoundException $propertyNotFoundException) {
55+
} catch (PropertyNotFoundException|ResourceClassNotFoundException $propertyNotFoundException) {
5556
return $propertyMetadata;
5657
}
5758

src/Metadata/Property/Factory/PropertyInfoPropertyMetadataFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@ public function create(string $resourceClass, string $property, array $options =
4949
}
5050
}
5151

52-
if ($propertyMetadata instanceof ApiProperty) {
53-
if (!$propertyMetadata->getBuiltinTypes()) {
54-
$propertyMetadata = $propertyMetadata->withBuiltinTypes($this->propertyInfo->getTypes($resourceClass, $property, $options) ?? []);
55-
}
56-
} elseif (null === $propertyMetadata->getType()) {
57-
$propertyMetadata = $propertyMetadata->withType($this->propertyInfo->getTypes($resourceClass, $property, $options)[0] ?? null);
52+
if (!$propertyMetadata->getBuiltinTypes()) {
53+
$propertyMetadata = $propertyMetadata->withBuiltinTypes($this->propertyInfo->getTypes($resourceClass, $property, $options) ?? []);
5854
}
5955

6056
if (null === $propertyMetadata->getDescription() && null !== $description = $this->propertyInfo->getShortDescription($resourceClass, $property, $options)) {

src/Metadata/Property/Factory/SerializerPropertyMetadataFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use ApiPlatform\Api\ResourceClassResolverInterface;
1717
use ApiPlatform\Exception\ResourceClassNotFoundException;
1818
use ApiPlatform\Metadata\ApiProperty;
19+
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyGroup;
1920
use ApiPlatform\Util\ResourceClassInfoTrait;
2021
use Symfony\Component\PropertyInfo\Type;
2122
use Symfony\Component\Serializer\Mapping\AttributeMetadataInterface;

src/Symfony/EventListener/QueryParameterValidateListener.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
namespace ApiPlatform\Symfony\EventListener;
1515

16-
use ApiPlatform\Core\Filter\QueryParameterValidator;
16+
use ApiPlatform\Core\Filter\QueryParameterValidator as LegacyQueryParameterValidator;
17+
use ApiPlatform\Api\QueryParameterValidator\QueryParameterValidator;
1718
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
1819
use ApiPlatform\Core\Metadata\Resource\ToggleableOperationAttributeTrait;
1920
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
@@ -39,8 +40,12 @@ final class QueryParameterValidateListener
3940
private $queryParameterValidator;
4041

4142
private $enabled;
42-
43-
public function __construct($resourceMetadataFactory, QueryParameterValidator $queryParameterValidator, bool $enabled = true)
43+
44+
/**
45+
* @param ResourceMetadataCollectionFactoryInterface|ResourceMetadataFactoryInterface $resourceMetadataFactory
46+
* @param QueryParameterValidator|LegacyQueryParameterValidator $queryParameterValidator
47+
*/
48+
public function __construct($resourceMetadataFactory, $queryParameterValidator, bool $enabled = true)
4449
{
4550
if (!$resourceMetadataFactory instanceof ResourceMetadataCollectionFactoryInterface) {
4651
trigger_deprecation('api-platform/core', '2.7', sprintf('Use "%s" instead of "%s".', ResourceMetadataCollectionFactoryInterface::class, ResourceMetadataFactoryInterface::class));

0 commit comments

Comments
 (0)