Skip to content

Commit d30df74

Browse files
authored
Merge pull request #4918 from soyuka/merge-27
Merge 2.7 and update changelog
2 parents 5ef1d61 + 2945098 commit d30df74

File tree

7 files changed

+158
-14
lines changed

7 files changed

+158
-14
lines changed

.commitlintrc

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"defaultIgnores": true,
3+
"parserPreset": "conventional-changelog-conventionalcommits",
4+
"rules": {
5+
"scope-enum": [
6+
2,
7+
"always",
8+
[
9+
"symfony",
10+
"doctrine",
11+
"metadata",
12+
"elasticsearch",
13+
"mongodb",
14+
"jsonld",
15+
"hydra",
16+
"jsonapi",
17+
"graphql",
18+
"openapi",
19+
"serializer",
20+
"jsonschema",
21+
"validation"
22+
]
23+
],
24+
"scope-empty": [
25+
2,
26+
"never"
27+
],
28+
"body-leading-blank": [
29+
1,
30+
"always"
31+
],
32+
"body-max-line-length": [
33+
2,
34+
"always",
35+
100
36+
],
37+
"footer-leading-blank": [
38+
1,
39+
"always"
40+
],
41+
"footer-max-line-length": [
42+
2,
43+
"always",
44+
100
45+
],
46+
"header-max-length": [
47+
2,
48+
"always",
49+
100
50+
],
51+
"subject-case": [
52+
2,
53+
"never",
54+
[
55+
"sentence-case",
56+
"start-case",
57+
"pascal-case",
58+
"upper-case"
59+
]
60+
],
61+
"subject-empty": [
62+
2,
63+
"never"
64+
],
65+
"subject-full-stop": [
66+
2,
67+
"never",
68+
"."
69+
],
70+
"type-case": [
71+
2,
72+
"always",
73+
"lower-case"
74+
],
75+
"type-empty": [
76+
2,
77+
"never"
78+
],
79+
"type-enum": [
80+
2,
81+
"always",
82+
[
83+
"build",
84+
"chore",
85+
"ci",
86+
"docs",
87+
"feat",
88+
"fix",
89+
"perf",
90+
"refactor",
91+
"revert",
92+
"style",
93+
"test"
94+
]
95+
]
96+
}
97+
}

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ env:
1010
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
1111

1212
jobs:
13+
commitlint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
configFile: .commitlintrc
20+
- uses: wagoid/commitlint-github-action@v5
1321
php-cs-fixer:
1422
name: PHP-cs-fixer (PHP ${{ matrix.php }})
1523
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
11
# Changelog
22
=======
33

4-
## 3.0.0-rc.3
4+
## 3.0.0
55

6-
* Symfony: removed the `$exceptionOnNoToken` parameter in `ResourceAccessChecker::__construct()` (#4900)
6+
* Symfony: 6.1 compatibility and remove 4.4 and 5.4 support (#4851)
7+
* Symfony: removed the $exceptionOnNoToken parameter in `ResourceAccessChecker::__construct()` (#4905)
8+
* Symfony: use conventional service names for Doctrine state providers and processors (#4859)
9+
* Symfony: adjust mapping paths to the SF best practices for Bundles **BC** `Resources/config/api_resources` to `config/api_resources` (#4853)
10+
* Symfony: `src/ApiResource/` is the recommended place for API models (#4874)
11+
* Cache: remove guzzle from the Varnish purger (#4872)
712

8-
## 3.0.0-beta.2
13+
Various cleanup in services and removal of backward compatibility layer.
14+
15+
## 2.7.0
16+
17+
* Metadata: do not set id when identifier is `false` (#4880)
18+
* Metadata: automatic GET operation when none is declared (#4881)
19+
* Metadata: exception to status on operations (#4861)
20+
* Serializer: adds the JSON_INVALID_UTF8_IGNORE flag to JsonEncode (#4741)
21+
* Symfony: autoconfigure legacy Doctrine extensions (#4909)
22+
* Elasticsearch: skip metadata without ES nodes (#4913)
23+
* Symfony: deprecate the $exceptionOnNoToken parameter in ResourceAccessChecker::__construct() (#4900)
24+
* Symfony: deprecated the `$exceptionOnNoToken` parameter in `ResourceAccessChecker::__construct()` (#4900)
25+
26+
Various cs fixes and PHPDoc to help upgrading to 3.0.
27+
28+
## 3.0.0-rc.2
29+
30+
* JsonLd: correct the `api_jsonld_context` route format (#4844)
31+
* Metadata: remove metadata_backward_compatibility_layer option (#4843)
32+
* OpenApi: fixed required fields (in and name) within `ApiPlatform\OpenApi\Model\Parameter` **BC**
33+
34+
Various cleanup, removed `Core` namespace leftovers and todos.
35+
36+
## 3.0.0-beta.2 / 3.0.0-rc.1
937

1038
* ExpressionLanguage: deprecated class `ApiPlatform\Symfony\Security\ExpressionLanguage` has been removed in favor of `Symfony\Component\Security\Core\Authorization\ExpressionLanguage`.
1139

@@ -21,6 +49,11 @@ Breaking changes:
2149
* Metadata: the `Core` namespace got removed (#4805)
2250
* Mercure: deprecation removed (#4805)
2351

52+
## 2.7.0-rc.2
53+
54+
* Symfony: the upgrade command now updates ApiFilter as well (#4845)
55+
* Symfony: maker command to create a state Processor (#4423)
56+
2457
## 2.7.0-beta.5
2558

2659
* Serializer: ignore no-operation on SerializeListener (#4828)

src/Elasticsearch/Metadata/Resource/Factory/ElasticsearchProviderResourceMetadataCollectionFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use ApiPlatform\Util\Inflector;
2222
use Elasticsearch\Client;
2323
use Elasticsearch\Common\Exceptions\Missing404Exception;
24+
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
2425

2526
final class ElasticsearchProviderResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
2627
{
@@ -88,6 +89,8 @@ private function hasIndices(string $shortName): bool
8889
return true;
8990
} catch (Missing404Exception) {
9091
return false;
92+
} catch (NoNodesAvailableException) {
93+
return false;
9194
}
9295
}
9396
}

src/GraphQl/Resolver/Stage/SerializeStage.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
use ApiPlatform\GraphQl\Serializer\ItemNormalizer;
1818
use ApiPlatform\GraphQl\Serializer\SerializerContextBuilderInterface;
1919
use ApiPlatform\Metadata\CollectionOperationInterface;
20+
use ApiPlatform\Metadata\GraphQl\Mutation;
2021
use ApiPlatform\Metadata\GraphQl\Operation;
22+
use ApiPlatform\Metadata\GraphQl\Subscription;
2123
use ApiPlatform\State\Pagination\Pagination;
2224
use ApiPlatform\State\Pagination\PaginatorInterface;
2325
use ApiPlatform\State\Pagination\PartialPaginatorInterface;
@@ -38,9 +40,9 @@ public function __construct(private readonly NormalizerInterface $normalizer, pr
3840

3941
public function __invoke(iterable|object|null $itemOrCollection, string $resourceClass, Operation $operation, array $context): ?array
4042
{
41-
$isCollection = $context['is_collection'] || $operation instanceof CollectionOperationInterface;
42-
$isMutation = $context['is_mutation'];
43-
$isSubscription = $context['is_subscription'];
43+
$isCollection = $operation instanceof CollectionOperationInterface;
44+
$isMutation = $operation instanceof Mutation;
45+
$isSubscription = $operation instanceof Subscription;
4446
$shortName = $operation->getShortName();
4547
$operationName = $operation->getName();
4648

src/JsonApi/Serializer/ItemNormalizer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ private function getIncludedNestedResources(string $relationshipName, array $con
445445
return array_map(static fn (string $nested): string => substr($nested, strpos($nested, '.') + 1), $filtered);
446446
}
447447

448+
// TODO: this code is similar to the one used in JsonLd
448449
private function getResourceShortName(string $resourceClass): string
449450
{
450451
if ($this->resourceClassResolver->isResourceClass($resourceClass)) {

tests/GraphQl/Resolver/Stage/SerializeStageTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,25 @@ protected function setUp(): void
5555
/**
5656
* @dataProvider applyDisabledProvider
5757
*/
58-
public function testApplyDisabled(array $context, bool $paginationEnabled, ?array $expectedResult): void
58+
public function testApplyDisabled(Operation $operation, bool $paginationEnabled, ?array $expectedResult): void
5959
{
6060
$resourceClass = 'myResource';
6161
/** @var Operation $operation */
62-
$operation = (new Query())->withSerialize(false);
62+
$operation = $operation->withSerialize(false);
6363

64-
$result = ($this->createSerializeStage($paginationEnabled))(null, $resourceClass, $operation, $context);
64+
$result = ($this->createSerializeStage($paginationEnabled))(null, $resourceClass, $operation, []);
6565

6666
$this->assertSame($expectedResult, $result);
6767
}
6868

6969
public function applyDisabledProvider(): array
7070
{
7171
return [
72-
'item' => [['is_collection' => false, 'is_mutation' => false, 'is_subscription' => false], false, null],
73-
'collection with pagination' => [['is_collection' => true, 'is_mutation' => false, 'is_subscription' => false], true, ['totalCount' => 0., 'edges' => [], 'pageInfo' => ['startCursor' => null, 'endCursor' => null, 'hasNextPage' => false, 'hasPreviousPage' => false]]],
74-
'collection without pagination' => [['is_collection' => true, 'is_mutation' => false, 'is_subscription' => false], false, []],
75-
'mutation' => [['is_collection' => false, 'is_mutation' => true, 'is_subscription' => false], false, ['clientMutationId' => null]],
76-
'subscription' => [['is_collection' => false, 'is_mutation' => false, 'is_subscription' => true], false, ['clientSubscriptionId' => null]],
72+
'item' => [new Query(), false, null],
73+
'collection with pagination' => [new QueryCollection(), true, ['totalCount' => 0., 'edges' => [], 'pageInfo' => ['startCursor' => null, 'endCursor' => null, 'hasNextPage' => false, 'hasPreviousPage' => false]]],
74+
'collection without pagination' => [new QueryCollection(), false, []],
75+
'mutation' => [new Mutation(), false, ['clientMutationId' => null]],
76+
'subscription' => [new Subscription(), false, ['clientSubscriptionId' => null]],
7777
];
7878
}
7979

0 commit comments

Comments
 (0)