Skip to content

Commit 3af3e93

Browse files
committed
serializer done
1 parent 1ddf2d3 commit 3af3e93

File tree

66 files changed

+2140
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2140
-197
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ jobs:
196196
- HttpCache
197197
- RamseyUuid
198198
- GraphQl
199+
- Serializer
199200
fail-fast: false
200201
steps:
201202
- name: Checkout

src/Api/IdentifiersExtractor.php

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

1414
namespace ApiPlatform\Api;
1515

16-
use ApiPlatform\Exception\RuntimeException;
16+
use ApiPlatform\Metadata\Exception\RuntimeException;
1717
use ApiPlatform\Metadata\GraphQl\Operation as GraphQlOperation;
1818
use ApiPlatform\Metadata\HttpOperation;
1919
use ApiPlatform\Metadata\Operation;
@@ -28,6 +28,8 @@
2828
/**
2929
* {@inheritdoc}
3030
*
31+
* @deprecated use ApiPlatform\Metadata\IdentifiersExtractor instead
32+
*
3133
* @author Antoine Bluchet <[email protected]>
3234
*/
3335
final class IdentifiersExtractor implements IdentifiersExtractorInterface

src/Api/IdentifiersExtractorInterface.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,10 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
use ApiPlatform\Exception\RuntimeException;
17-
use ApiPlatform\Metadata\Operation;
16+
class_exists(\ApiPlatform\Metadata\IdentifiersExtractorInterface::class);
1817

19-
/**
20-
* Extracts identifiers for a given Resource according to the retrieved Metadata.
21-
*
22-
* @author Antoine Bluchet <[email protected]>
23-
*/
24-
interface IdentifiersExtractorInterface
25-
{
26-
/**
27-
* Finds identifiers from an Item (object).
28-
*
29-
* @throws RuntimeException
30-
*/
31-
public function getIdentifiersFromItem(object $item, Operation $operation = null, array $context = []): array;
18+
if (!class_exists(IdentifiersExtractorInterface::class)) {
19+
interface IdentifiersExtractorInterface extends \ApiPlatform\Metadata\IdentifiersExtractorInterface
20+
{
21+
}
3222
}

src/Api/IriConverterInterface.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
interface IriConverterInterface extends \ApiPlatform\Metadata\IriConverterInterface
17-
{
16+
class_exists(\ApiPlatform\Metadata\IriConverterInterface::class);
17+
18+
if (!class_exists(IriConverterInterface::class)) {
19+
interface IriConverterInterface extends \ApiPlatform\Metadata\IriConverterInterface
20+
{
21+
}
1822
}

src/Api/ResourceClassResolverInterface.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
interface ResourceClassResolverInterface extends \ApiPlatform\Metadata\ResourceClassResolverInterface
17-
{
16+
class_exists(\ApiPlatform\Metadata\ResourceClassResolverInterface::class);
17+
18+
if (false) {
19+
interface ResourceClassResolverInterface extends \ApiPlatform\Metadata\ResourceClassResolverInterface
20+
{
21+
}
1822
}

src/Api/UriVariablesConverterInterface.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,10 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
use ApiPlatform\Exception\InvalidIdentifierException;
16+
class_exists(\ApiPlatform\Metadata\UriVariablesConverterInterface::class);
1717

18-
/**
19-
* Identifier converter.
20-
*
21-
* @author Antoine Bluchet <[email protected]>
22-
*/
23-
interface UriVariablesConverterInterface
24-
{
25-
/**
26-
* Takes an array of strings representing URI variables (identifiers) and transform their values to the expected type.
27-
*
28-
* @param array $data URI variables to convert to PHP values
29-
* @param string $class The class to which the URI variables belong to
30-
*
31-
* @throws InvalidIdentifierException
32-
*
33-
* @return array Array indexed by identifiers properties with their values denormalized
34-
*/
35-
public function convert(array $data, string $class, array $context = []): array;
18+
if (!class_exists(UriVariablesConverterInterface::class)) {
19+
interface UriVariablesConverterInterface extends \ApiPlatform\Metadata\UriVariablesConverterInterface
20+
{
21+
}
3622
}

src/Elasticsearch/composer.json

Lines changed: 75 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,82 @@
11
{
2-
"name": "api-platform/elasticseach",
3-
"description": "Elasticsearch support",
4-
"type": "library",
5-
"keywords": [
6-
"Filter",
7-
"Elasticsearch"
8-
],
9-
"homepage": "https://api-platform.com",
10-
"license": "MIT",
11-
"authors": [
12-
{
13-
"name": "Kévin Dunglas",
14-
"email": "[email protected]",
15-
"homepage": "https://dunglas.fr"
2+
"name": "api-platform/elasticseach",
3+
"description": "Elasticsearch support",
4+
"type": "library",
5+
"keywords": [
6+
"Filter",
7+
"Elasticsearch"
8+
],
9+
"homepage": "https://api-platform.com",
10+
"license": "MIT",
11+
"authors": [
12+
{
13+
"name": "Kévin Dunglas",
14+
"email": "[email protected]",
15+
"homepage": "https://dunglas.fr"
16+
},
17+
{
18+
"name": "API Platform Community",
19+
"homepage": "https://api-platform.com/community/contributors"
20+
}
21+
],
22+
"require": {
23+
"php": ">=8.1",
24+
"api-platform/metadata": "*@dev || ^3.1",
25+
"api-platform/state": "*@dev || ^3.1",
26+
"api-platform/serializer": "*@dev || ^3.1",
27+
"elasticsearch/elasticsearch": "^7.11.0",
28+
"symfony/cache": "^6.1",
29+
"symfony/console": "^6.2",
30+
"symfony/property-info": "^6.1",
31+
"symfony/serializer": "^6.1",
32+
"symfony/uid": "^6.1",
33+
"symfony/property-access": "^6.1"
1634
},
17-
{
18-
"name": "API Platform Community",
19-
"homepage": "https://api-platform.com/community/contributors"
20-
}
21-
],
22-
"require": {
23-
"php": ">=8.1",
24-
"api-platform/metadata": "*@dev || ^3.1",
25-
"api-platform/state": "*@dev || ^3.1",
26-
"elasticsearch/elasticsearch": "^7.11.0",
27-
"symfony/cache": "^6.1",
28-
"symfony/console": "^6.2",
29-
"symfony/property-info": "^6.1",
30-
"symfony/serializer": "^6.1",
31-
"symfony/uid": "^6.1",
32-
"symfony/property-access": "^6.1"
33-
},
34-
"conflict": {
35-
"elasticsearch/elasticsearch": ">=8.0"
36-
},
37-
"require-dev": {
38-
"phpspec/prophecy-phpunit": "^2.0",
39-
"symfony/phpunit-bridge": "^6.1"
40-
},
41-
"autoload": {
42-
"psr-4": {
43-
"ApiPlatform\\Elasticsearch\\": ""
35+
"conflict": {
36+
"elasticsearch/elasticsearch": ">=8.0"
4437
},
45-
"exclude-from-classmap": [
46-
"/Tests/"
47-
]
48-
},
49-
"config": {
50-
"preferred-install": {
51-
"*": "dist"
38+
"require-dev": {
39+
"phpspec/prophecy-phpunit": "^2.0",
40+
"symfony/phpunit-bridge": "^6.1"
41+
},
42+
"autoload": {
43+
"psr-4": {
44+
"ApiPlatform\\Elasticsearch\\": ""
45+
},
46+
"exclude-from-classmap": [
47+
"/Tests/"
48+
]
5249
},
53-
"sort-packages": true,
54-
"allow-plugins": {
55-
"composer/package-versions-deprecated": true,
56-
"phpstan/extension-installer": true
57-
}
58-
},
59-
"extra": {
60-
"branch-alias": {
61-
"dev-main": "3.2.x-dev"
50+
"config": {
51+
"preferred-install": {
52+
"*": "dist"
53+
},
54+
"sort-packages": true,
55+
"allow-plugins": {
56+
"composer/package-versions-deprecated": true,
57+
"phpstan/extension-installer": true
58+
}
6259
},
63-
"symfony": {
64-
"require": "^6.1"
65-
}
66-
},
67-
"repositories": [
68-
{
69-
"type": "path",
70-
"url": "../Metadata"
60+
"extra": {
61+
"branch-alias": {
62+
"dev-main": "3.2.x-dev"
63+
},
64+
"symfony": {
65+
"require": "^6.1"
66+
}
7167
},
72-
{
73-
"type": "path",
74-
"url": "../State"
75-
}
76-
]
68+
"repositories": [
69+
{
70+
"type": "path",
71+
"url": "../Metadata"
72+
},
73+
{
74+
"type": "path",
75+
"url": "../State"
76+
},
77+
{
78+
"type": "path",
79+
"url": "../Serializer"
80+
}
81+
]
7782
}

src/Exception/InvalidArgumentException.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313

1414
namespace ApiPlatform\Exception;
1515

16+
use ApiPlatform\Metadata\Exception\InvalidArgumentException as MetadataInvalidArgumentException;
17+
1618
/**
1719
* Invalid argument exception.
1820
*
1921
* @author Kévin Dunglas <[email protected]>
22+
*
23+
* @deprecated use \ApiPlatform\Metadata\Exception\InvalidArgumentException
2024
*/
21-
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
25+
class InvalidArgumentException extends MetadataInvalidArgumentException
2226
{
2327
}

src/GraphQl/Serializer/ItemNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace ApiPlatform\GraphQl\Serializer;
1515

16-
use ApiPlatform\Api\IdentifiersExtractorInterface;
1716
use ApiPlatform\Metadata\ApiProperty;
17+
use ApiPlatform\Metadata\IdentifiersExtractorInterface;
1818
use ApiPlatform\Metadata\IriConverterInterface;
1919
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
2020
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;

src/GraphQl/Tests/Fixtures/Type/Definition/DateTimeType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function parseValue($value): string
7878
/**
7979
* {@inheritdoc}
8080
*/
81-
public function parseLiteral(Node $valueNode, ?array $variables = null): string
81+
public function parseLiteral(Node $valueNode, array $variables = null): string
8282
{
8383
if ($valueNode instanceof StringValueNode && false !== \DateTime::createFromFormat(\DateTime::ATOM, $valueNode->value)) {
8484
return $valueNode->value;

0 commit comments

Comments
 (0)