Skip to content

Commit 5032f46

Browse files
author
roadiz-ci
committed
feat: Allow WebResponse object instantiation overriding
1 parent 5a5af09 commit 5032f46

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Api/DataTransformer/WebResponseDataTransformerInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ public function transform($object, string $to, array $context = []): ?WebRespons
2525
* @param object|array $data object on normalize / array on denormalize
2626
*/
2727
public function supportsTransformation($data, string $to, array $context = []): bool;
28+
29+
public function createWebResponse(): WebResponseInterface;
2830
}

src/Api/DataTransformer/WebResponseOutputDataTransformer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ protected function getRealmResolver(): RealmResolverInterface
6969
return $this->realmResolver;
7070
}
7171

72+
public function createWebResponse(): WebResponse
73+
{
74+
return new WebResponse();
75+
}
76+
7277
/**
7378
* @inheritDoc
7479
*/
@@ -80,7 +85,7 @@ public function transform($object, string $to, array $context = []): ?WebRespons
8085
PersistableInterface::class
8186
);
8287
}
83-
$output = new WebResponse();
88+
$output = $this->createWebResponse();
8489
$output->item = $object;
8590
if ($object instanceof NodesSources) {
8691
$this->injectRealms($output, $object);

0 commit comments

Comments
 (0)