|
36 | 36 | */
|
37 | 37 | final class UserContextListener implements EventSubscriberInterface
|
38 | 38 | {
|
39 |
| - private RequestMatcherInterface $requestMatcher; |
40 |
| - private HashGenerator $hashGenerator; |
41 |
| - |
42 |
| - /** |
43 |
| - * If the response tagger is set, the hash lookup response is tagged with the session id for later invalidation. |
44 |
| - */ |
45 |
| - private ?ResponseTagger $responseTagger; |
46 |
| - |
47 | 39 | private array $options;
|
48 | 40 |
|
49 |
| - /** |
50 |
| - * Whether the application has a session listener and therefore could |
51 |
| - * require the AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER. |
52 |
| - */ |
53 |
| - private bool $hasSessionListener; |
54 |
| - |
55 | 41 | private bool $wasAnonymous = false;
|
56 | 42 |
|
57 |
| - /** |
58 |
| - * Used to exclude anonymous requests (no authentication nor session) from user hash sanity check. |
59 |
| - * It prevents issues when the hash generator that is used returns a customized value for anonymous users, |
60 |
| - * that differs from the documented, hardcoded one. |
61 |
| - */ |
62 |
| - private ?RequestMatcherInterface $anonymousRequestMatcher; |
63 |
| - |
64 | 43 | public function __construct(
|
65 |
| - RequestMatcherInterface $requestMatcher, |
66 |
| - HashGenerator $hashGenerator, |
67 |
| - ?RequestMatcherInterface $anonymousRequestMatcher = null, |
68 |
| - ?ResponseTagger $responseTagger = null, |
| 44 | + private readonly RequestMatcherInterface $requestMatcher, |
| 45 | + private readonly HashGenerator $hashGenerator, |
| 46 | + /** |
| 47 | + * Used to exclude anonymous requests (no authentication nor session) from user hash sanity check. |
| 48 | + * It prevents issues when the hash generator that is used returns a customized value for anonymous users, |
| 49 | + * that differs from the documented, hardcoded one. |
| 50 | + */ |
| 51 | + private readonly ?RequestMatcherInterface $anonymousRequestMatcher = null, |
| 52 | + /** |
| 53 | + * If the response tagger is set, the hash lookup response is tagged with the session id for later invalidation. |
| 54 | + */ |
| 55 | + private readonly ?ResponseTagger $responseTagger = null, |
69 | 56 | array $options = [],
|
70 |
| - bool $hasSessionListener = true |
| 57 | + /** |
| 58 | + * Whether the application has a session listener and therefore could |
| 59 | + * require the AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER. |
| 60 | + */ |
| 61 | + private readonly bool $hasSessionListener = true |
71 | 62 | ) {
|
72 |
| - $this->requestMatcher = $requestMatcher; |
73 |
| - $this->hashGenerator = $hashGenerator; |
74 |
| - $this->anonymousRequestMatcher = $anonymousRequestMatcher; |
75 |
| - $this->responseTagger = $responseTagger; |
76 |
| - $this->hasSessionListener = $hasSessionListener; |
77 |
| - |
78 | 63 | $resolver = new OptionsResolver();
|
79 | 64 | $resolver->setDefaults([
|
80 | 65 | 'user_identifier_headers' => ['Cookie', 'Authorization'],
|
|
0 commit comments