Skip to content

Commit

Permalink
Set proper encoding format
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Sep 4, 2024
1 parent 28e34f4 commit f2ed4a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ services:
$normalizer: '@ibexa.rest.serializer'
$encoder: '@ibexa.rest.serializer.encoder.json'
$valueObjectVisitorResolver: '@Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolver'
$format: 'json'
tags:
- { name: ibexa.rest.output.visitor, regexps: ibexa.rest.output.visitor.json.regexps }

Expand All @@ -334,6 +335,7 @@ services:
$normalizer: '@ibexa.rest.serializer'
$encoder: '@ibexa.rest.serializer.encoder.xml'
$valueObjectVisitorResolver: '@Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolver'
$format: 'xml'
tags:
- { name: ibexa.rest.output.visitor, regexps: ibexa.rest.output.visitor.xml.regexps }

Expand Down
3 changes: 2 additions & 1 deletion src/contracts/Output/Visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(
private readonly NormalizerInterface $normalizer,
private readonly EncoderInterface $encoder,
private readonly ValueObjectVisitorResolverInterface $valueObjectVisitorResolver,
private readonly string $format,
) {
$this->response = new Response('', 200);
}
Expand Down Expand Up @@ -88,7 +89,7 @@ public function visit(mixed $data): Response

$response = clone $this->response;

$response->setContent($this->encoder->encode($normalizedData, 'json'));
$response->setContent($this->encoder->encode($normalizedData, $this->format));

// reset the inner response
$this->response = new Response(null, Response::HTTP_OK);
Expand Down
1 change: 1 addition & 0 deletions src/contracts/Output/VisitorAdapterNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private function createVisitor(): Visitor
$this->normalizer,
$this->encoder,
$this->valueObjectVisitorResolver,
'json',
);
}
}

0 comments on commit f2ed4a7

Please sign in to comment.