8000 Consider removing allowCustomResponseCode() · Issue #22019 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Consider removing allowCustomResponseCode() #22019
Closed
@javiereguiluz

Description

@javiereguiluz
Q A
Bug report? no
Feature request? yes
BC Break report? no
Symfony version 3.3

While writing the New in Symfony 3.3: Deprecated X-Status-Code blog post, I wondered why we need allowCustomResponseCode(). Let me show some code:

This is what we have in Symfony 3.2

$exception = $event->getException();
$response = new Response('...', 500, ['X-Status-Code' => 404]);
$event->setResponse($response);

This is the solution proposed by Symfony 3.3

$exception = $event->getException();
$response = new Response('...', 404);
$event->allowCustomResponseCode();
$event->setResponse($response);

This is what I want

$exception = $event->getException();
$response = new Response('...', 404);
$event->setResponse($response);

Removing X-Status-Code is great and help us reduce the "cognitive load" required to use Symfony ... but all those gains are lost when introducing allowCustomResponseCode().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0