Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/JsonLd/Action/ContextAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
*/
final class ContextAction
{
public const RESERVED_SHORT_NAMES = [
'ConstraintViolationList' => true,
'Error' => true,
];

public function __construct(
private readonly ContextBuilderInterface $contextBuilder,
private readonly ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory,
Expand Down Expand Up @@ -90,11 +85,6 @@ private function getContext(string $shortName): ?array
return ['@context' => $this->contextBuilder->getEntrypointContext()];
}

// TODO: remove this, exceptions are resources since 3.2
if (isset(self::RESERVED_SHORT_NAMES[$shortName])) {
return ['@context' => $this->contextBuilder->getBaseContext()];
}

foreach ($this->resourceNameCollectionFactory->create() as $resourceClass) {
$resourceMetadataCollection = $this->resourceMetadataCollectionFactory->create($resourceClass);

Expand Down
9 changes: 0 additions & 9 deletions src/Serializer/SerializerContextBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ public function createFromRequest(Request $request, bool $normalization, ?array
$context['types'] = $types;
}

// TODO: remove this as uri variables are available in the SerializerProcessor but correctly parsed
if ($operation->getUriVariables()) {
$context['uri_variables'] = [];

foreach (array_keys($operation->getUriVariables()) as $parameterName) {
$context['uri_variables'][$parameterName] = $request->attributes->get($parameterName);
}
}

if (null === $context['output'] && $this->getStateOptionsClass($operation)) {
$context['force_resource_class'] = $operation->getClass();
}
Expand Down
18 changes: 18 additions & 0 deletions tests/Functional/JsonLd/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,22 @@ public function testResourceLevelJsonLdContextAddsNamespacePrefixes(): void
$this->assertSame('http://purl.org/dc/terms/', $body['@context']['dct']);
$this->assertSame('dct:title', $body['@context']['title']);
}

public function testErrorContextIsResolvedThroughItsResource(): void
{
$response = self::createClient()->request('GET', '/contexts/Error');
$this->assertResponseIsSuccessful();
$body = $response->toArray();
$this->assertArrayHasKey('@context', $body);
$this->assertSame('http://www.w3.org/ns/hydra/core#', $body['@context']['hydra']);
}

public function testConstraintViolationContextIsResolvedThroughItsResource(): void
{
$response = self::createClient()->request('GET', '/contexts/ConstraintViolation');
$this->assertResponseIsSuccessful();
$body = $response->toArray();
$this->assertArrayHasKey('@context', $body);
$this->assertSame('http://www.w3.org/ns/hydra/core#', $body['@context']['hydra']);
}
}
Loading