Skip to content

Commit 8e68d72

Browse files
committed
Revert "fix(jsonld): reset gen_id configuration"
This reverts commit 454fe71.
1 parent f824644 commit 8e68d72

File tree

6 files changed

+3
-101
lines changed

6 files changed

+3
-101
lines changed

src/JsonLd/Serializer/ItemNormalizer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
124124
unset($context['operation'], $context['operation_name']);
125125
}
126126

127-
$operation = $context['operation'] ?? null;
128-
if (true === ($context['output']['gen_id'] ?? true) && true === ($context['force_iri_generation'] ?? true) && $iri = $this->iriConverter->getIriFromResource($object, $operation?->getUrlGenerationStrategy() ?? UrlGeneratorInterface::ABS_PATH, $operation, $context)) {
127+
if (true === ($context['output']['gen_id'] ?? true) && true === ($context['force_iri_generation'] ?? true) && $iri = $this->iriConverter->getIriFromResource($object, UrlGeneratorInterface::ABS_PATH, $context['operation'] ?? null, $context)) {
129128
$context['iri'] = $iri;
130129
$metadata['@id'] = $iri;
131130
}

src/Serializer/OperationContextTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function createOperationContext(array $context, ?string $resourceClass
3434
$context['root_operation_name'] = $context['operation_name'] ?? $context['graphql_operation_name'];
3535
}
3636

37-
unset($context['iri'], $context['uri_variables'], $context['item_uri_template'], $context['force_resource_class'], $context['output']['gen_id']);
37+
unset($context['iri'], $context['uri_variables'], $context['item_uri_template'], $context['force_resource_class']);
3838

3939
// At some point we should merge the jsonld context here, there's a TODO to simplify this somewhere else
4040
if ($propertyMetadata) {

tests/Fixtures/TestBundle/ApiResource/GenIdFalse/LevelFirst.php

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

tests/Fixtures/TestBundle/ApiResource/GenIdFalse/LevelSecond.php

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

tests/Fixtures/TestBundle/ApiResource/GenIdFalse/LevelThird.php

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

tests/Functional/JsonLdTest.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
1717
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\GenIdFalse\AggregateRating;
1818
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\GenIdFalse\GenIdFalse;
19-
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\GenIdFalse\LevelFirst;
20-
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\GenIdFalse\LevelSecond;
21-
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\GenIdFalse\LevelThird;
2219
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6810\JsonLdContextOutput;
2320
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue6465\Bar;
2421
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue6465\Foo;
@@ -37,7 +34,7 @@ class JsonLdTest extends ApiTestCase
3734
*/
3835
public static function getResources(): array
3936
{
40-
return [Foo::class, Bar::class, JsonLdContextOutput::class, GenIdFalse::class, AggregateRating::class, LevelFirst::class, LevelSecond::class, LevelThird::class];
37+
return [Foo::class, Bar::class, JsonLdContextOutput::class, GenIdFalse::class, AggregateRating::class];
4138
}
4239

4340
/**
@@ -84,19 +81,6 @@ public function testGenIdFalseOnResource(): void
8481
$this->assertArrayNotHasKey('@id', $r->toArray()['aggregateRating']);
8582
}
8683

87-
public function testGenIdFalseOnNestedResource(): void
88-
{
89-
$r = self::createClient()->request(
90-
'GET',
91-
'/levelfirst/1',
92-
);
93-
$this->assertJsonContains([
94-
'levelSecond' => [
95-
'levelThird' => '/levelthird/3',
96-
],
97-
]);
98-
}
99-
10084
public function testShouldIgnoreProperty(): void
10185
{
10286
$r = self::createClient()->request(

0 commit comments

Comments
 (0)