This PR was submitted for the master branch but it was merged into the 2.6 branch instead (closes #14930).
Discussion
----------
Bug #14836 [HttpFoundation] Moves default JSON encoding assignment fr…
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | no
| Fixed tickets | #14918, #14836
| License | MIT
| Doc PR | no
Moves the assignment of the encoding flags to a property so the class can be extended without needing to re-write the constructor and perform the encoding of data twice.
For more information please see https://github.com/symfony/symfony/issues/14836
Commits
-------
25e0d63
Bug #14836 [HttpFoundation] Moves default JSON encoding assignment from constructor to property
This commit is contained in:
commit
88e99d2244
@ -26,7 +26,10 @@ class JsonResponse extends Response
|
|||||||
{
|
{
|
||||||
protected $data;
|
protected $data;
|
||||||
protected $callback;
|
protected $callback;
|
||||||
protected $encodingOptions;
|
|
||||||
|
// Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML.
|
||||||
|
// 15 === JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT
|
||||||
|
protected $encodingOptions = 15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -43,9 +46,6 @@ class JsonResponse extends Response
|
|||||||
$data = new \ArrayObject();
|
$data = new \ArrayObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML.
|
|
||||||
$this->encodingOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
|
|
||||||
|
|
||||||
$this->setData($data);
|
$this->setData($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user