Skip to content

Commit

Permalink
feat: Allow WebResponse object instantiation overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Feb 9, 2024
1 parent d7fe7af commit 8690594
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ public function transform($object, string $to, array $context = []): ?WebRespons
* @param object|array $data object on normalize / array on denormalize
*/
public function supportsTransformation($data, string $to, array $context = []): bool;

public function createWebResponse(): WebResponseInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ protected function getRealmResolver(): RealmResolverInterface
return $this->realmResolver;
}

public function createWebResponse(): WebResponse
{
return new WebResponse();
}

/**
* @inheritDoc
*/
Expand All @@ -80,7 +85,7 @@ public function transform($object, string $to, array $context = []): ?WebRespons
PersistableInterface::class
);
}
$output = new WebResponse();
$output = $this->createWebResponse();
$output->item = $object;
if ($object instanceof NodesSources) {
$this->injectRealms($output, $object);
Expand Down

0 comments on commit 8690594

Please sign in to comment.