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

Introduce custom attributes for Responses #30578

Closed
shyim opened this issue Mar 15, 2019 · 4 comments
Closed

Introduce custom attributes for Responses #30578

shyim opened this issue Mar 15, 2019 · 4 comments

Comments

@shyim
Copy link
Contributor

shyim commented Mar 15, 2019

Description
The request object have attributes property where application can save custom informations. This possibility is missing on responses. (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L74)

I am migrating currently a project that uses ZF1 Request and Response object. The Response object has a method to set exceptions to this Response. Since I want to replace only the Request and Response object I have to support that also as Response object from the HttpFoundation.

So my idea was to add that property also to the Response object

I would also create a PR for that :)

Example

$response= new Response();
$response->attributes->set('something', true);
@stof
Copy link
Member

stof commented Mar 18, 2019

What would be the use case for that ?

@shyim
Copy link
Contributor Author

shyim commented Mar 18, 2019

To store custom informations like exceptions occurred in this request response cycle (Who don't use the complete Symfony Framework)

@ro0NL
Copy link
Contributor

ro0NL commented Mar 19, 2019

Do you really need to use Symfony Response for that? I'm not sure it's valid just because Zend Response does it.

The Response object has a method to set exceptions to this Response.

ZF will handle it as such i assume? Symfony has no such concept, so i'm not sure what you're expecting?

If it's just to transfer attribtues/anything, i don't think you need the Response object for that per se. Or at least i dont think core should provide something for that.

@fabpot
Copy link
Member

fabpot commented Mar 20, 2019

The Response is probably not the right class to store additional information.

@fabpot fabpot closed this as completed Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants