minor #36379 Fix constant accessor (driesvints)
This PR was squashed before being merged into the 5.1-dev branch.
Discussion
----------
Fix constant accessor
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix #... <!-- prefix each issue number with "Fix #", if any -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
Because HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES is private, using static will fail for any classes extending the Response class. HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES is already properly using self a bit lower so we should do the same thing here.
Introduced in https://github.com/symfony/symfony/pull/35748
Commits
-------
633ff5b214
Fix constant accessor
This commit is contained in:
commit
aa44db0da0
@ -949,7 +949,7 @@ class Response
|
||||
*/
|
||||
public function setCache(array $options): object
|
||||
{
|
||||
if ($diff = array_diff(array_keys($options), array_keys(static::HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES))) {
|
||||
if ($diff = array_diff(array_keys($options), array_keys(self::HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES))) {
|
||||
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff)));
|
||||
}
|
||||
|
||||
|
@ -672,6 +672,12 @@ class ResponseTest extends ResponseTestCase
|
||||
|
||||
$this->assertFalse($response->headers->hasCacheControlDirective(str_replace('_', '-', $directive)));
|
||||
}
|
||||
|
||||
$response = new DefaultResponse();
|
||||
|
||||
$options = ['etag' => '"whatever"'];
|
||||
$response->setCache($options);
|
||||
$this->assertSame($response->getEtag(), '"whatever"');
|
||||
}
|
||||
|
||||
public function testSendContent()
|
||||
|
Reference in New Issue
Block a user