Skip to content

Update events.rst #6857

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

Merged
merged 1 commit into from
Dec 15, 2016
Merged

Update events.rst #6857

merged 1 commit into from
Dec 15, 2016

Conversation

tabbi89
Copy link
Contributor

@tabbi89 tabbi89 commented Aug 6, 2016

What I have done here is just a complete explanation what is going on during setting response status code. Sentence setting the status on the response won't work is not true because if we pass "proper status code" it will be passed to final response without further checks - condition: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/HttpKernel.php#L248. So for example If I do something like this

// ...
$exception = $event->getException();
$response = new Response();
// setup the Response object based on the caught exception
$event->setResponse($response);
$event->setStatusCode(400);

Finally 400 status code will be passed to response!

In my opinion current documentation is incorrect and as a developer I would like to have valid information. Maybe what I wrote is too precise maybe a reference to code would be a better option ? Thanks a lot.

@weaverryan weaverryan merged commit 4db1863 into symfony:2.7 Dec 15, 2016
weaverryan added a commit that referenced this pull request Dec 15, 2016
This PR was merged into the 2.7 branch.

Discussion
----------

Update events.rst

What I have done here is just a complete explanation what is going on during setting response status code. Sentence `setting the status on the response won't work` is not true because if we pass "proper status code" it will be passed to final response without further checks - condition: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/HttpKernel.php#L248. So for example If I do something like this

``` php
// ...
$exception = $event->getException();
$response = new Response();
// setup the Response object based on the caught exception
$event->setResponse($response);
$event->setStatusCode(400);
```

Finally 400 status code will be passed to response!

In my opinion current documentation is incorrect and as a developer I would like to have valid information. Maybe what I wrote is too precise maybe a reference to code would be a better option ? Thanks a lot.

Commits
-------

4db1863 Update events.rst
weaverryan added a commit that referenced this pull request Dec 15, 2016
@weaverryan
Copy link
Member

Hey @tabbi89! Thanks for the PR and sorry for the delay! I've just merged this in, with some changes at sha: bf7c94d

Cheers!

weaverryan added a commit that referenced this pull request Dec 15, 2016
* 2.7: (22 commits)
  [#6894] Adding link to Doctrine
  [#6857] Re-wording the section a bit
  [#6840] Adding note based on Stof's feedback
  Moving file - I think configuration is more appropriate
  Revert "Updated the contents for the new Symfony 3 dir structure"
  Updated the contents for the new Symfony 3 dir structure
  Remove "Symfony3 will use"
  Using lower case on "Form"
  Made a bunch of fixes recommended by Ryan
  Added a note about rendering templates from different kernels
  Added a new section about running commands under a different kernel
  Integrated improvement by javiereguiluz
  Explain what happens if `flush()` fails
  Update events.rst
  Added a new use case related to micro-services
  Removed a use case
  Reworded the use cases section
  Fixed typo
  Fixed an example code
  Fixed another syntax issue
  ...
weaverryan added a commit that referenced this pull request Dec 15, 2016
* 2.8: (22 commits)
  [#6894] Adding link to Doctrine
  [#6857] Re-wording the section a bit
  [#6840] Adding note based on Stof's feedback
  Moving file - I think configuration is more appropriate
  Revert "Updated the contents for the new Symfony 3 dir structure"
  Updated the contents for the new Symfony 3 dir structure
  Remove "Symfony3 will use"
  Using lower case on "Form"
  Made a bunch of fixes recommended by Ryan
  Added a note about rendering templates from different kernels
  Added a new section about running commands under a different kernel
  Integrated improvement by javiereguiluz
  Explain what happens if `flush()` fails
  Update events.rst
  Added a new use case related to micro-services
  Removed a use case
  Reworded the use cases section
  Fixed typo
  Fixed an example code
  Fixed another syntax issue
  ...
weaverryan added a commit that referenced this pull request Dec 15, 2016
* 3.1: (25 commits)
  [#6894] Adding link to Doctrine
  [#6857] Re-wording the section a bit
  [#6840] Adding note based on Stof's feedback
  Moving file - I think configuration is more appropriate
  Revert "Updated the contents for the new Symfony 3 dir structure"
  Updated the contents for the new Symfony 3 dir structure
  Remove "Symfony3 will use"
  Using lower case on "Form"
  Make lines shorter to comply with our soft limit of 80 chars per line
  Made a bunch of fixes recommended by Ryan
  Added a note about rendering templates from different kernels
  Fix comments
  [Serializer] Docs for the @MaxDepth annotation
  Added a new section about running commands under a different kernel
  Integrated improvement by javiereguiluz
  Explain what happens if `flush()` fails
  Update events.rst
  Added a new use case related to micro-services
  Removed a use case
  Reworded the use cases section
  ...
weaverryan added a commit that referenced this pull request Dec 15, 2016
* 3.2: (26 commits)
  [#6894] Adding link to Doctrine
  [#6857] Re-wording the section a bit
  [#6840] Adding note based on Stof's feedback
  Moving file - I think configuration is more appropriate
  Revert "Updated the contents for the new Symfony 3 dir structure"
  Updated the contents for the new Symfony 3 dir structure
  Remove "Symfony3 will use"
  Using lower case on "Form"
  Added a mention to sameSite cookie option
  Make lines shorter to comply with our soft limit of 80 chars per line
  Made a bunch of fixes recommended by Ryan
  Added a note about rendering templates from different kernels
  Fix comments
  [Serializer] Docs for the @MaxDepth annotation
  Added a new section about running commands under a different kernel
  Integrated improvement by javiereguiluz
  Explain what happens if `flush()` fails
  Update events.rst
  Added a new use case related to micro-services
  Removed a use case
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants