symfony/symfony — pull request #3660 by olegstepura (2012-03-21 09:18:12+00:00)
Title: Let Request know about response and vice versa

```
Bug fix: [no]
Feature addition: [yes]
Backwards compatibility break: [no]
Symfony2 tests pass: [yes] (actualy I got some not related to this pull request errors as described here: https://groups.google.com/forum/#!topic/symfony-devs/EFDgwVSUcpw)
Fixes the following tickets: -
Todo: -
```

Hi!

This pull request is to add some extra abilities to the `Request` and `Reponse` classes. Those are the `Request::setResponse` and `Response::setRequest` methods and the corresponding getters

This was done to allow even more intuitive syntax in my pull request to SensioFrameworkExtraBundle: https://github.com/sensio/SensioFrameworkExtraBundle/pull/105

After this merge it would be possible to write `$this->getRequest()->getResponse()->headers->setCookie(new Cookie('test', 123))`
there. Also it is logical to let request know about the related response and vice versa since this pair always acts together.

I also suggest adding `getResponse($streamed = false)` to default Controller class so that if no response is generated in an Action - an empty new one would be generated (and to keep track of it) (FYI: it's already created in `Controller::stream()` and when `Controller::render()` is called). I can add such changes into this pull request as well if nobody is against it.