Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HasReponse only works on single item #355

Closed
aerni opened this issue Dec 20, 2023 · 1 comment
Closed

HasReponse only works on single item #355

aerni opened this issue Dec 20, 2023 · 1 comment

Comments

@aerni
Copy link

aerni commented Dec 20, 2023

I'm following the docs on how to add the response to a DTO. This works as expected for a single item like a server.

If you've got a response containing multiple items (servers), you can create a DTO for each server. Similar to this example in the discussion.

However, the response won't be added to each individual DTO. I am not sure if this is a bug or a missing feature.

@Sammyjo20
Copy link
Collaborator

Hey @aerni this is expected behaviour I'm afraid. If you need to include the response on every DTO you should pass it into your DTO yourself. Perhaps you could implement your own solution like:

<?php

class DTO {
     public function __construct(
          public Response $response,
          public string $otherProperty,
          // etc...
     )
     {}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants