Repository navigation
Replies: 2 comments 1 reply
|
You'd need some kind of adapter/decorator to hydrate the array into a DTO if you wanted it to be handled when final class DTOAdapter implements AdapterInterface
{
public function __construct(
private readonly AdapterInterface $decoratedAdapter,
) {}
public function getNbResults(): int
{
return $this->decoratedAdapter->getNbResults();
}
public function getSlice(int $offset, int $length): iterable
{
$rawData = $this->decoratedAdapter->getSlice($offset, $length);
$dtos = [];
foreach ($rawData as $row) {
// Replace with the actual logic to convert the array to your DTO
$item = new Foo();
$dtos[] = $item;
}
return $dtos;
}
} |
1 reply
|
And I found another way for this issue, uses |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
In DBAL 3 will dropped support fetching objects with custom class like:
Therefore, now in the array
$articlesthere will be a regular associative array, instead of `ArticleDTO[]'. Is it possible to substitute the output of the getCurrentPageResults() method?Or maybe there is another solution so that
GetCurrentPageResults()returns an array ofArticleDTOobjects?All reactions