1 | <?php |
||
31 | abstract class HttpCache extends BaseHttpCache |
||
32 | { |
||
33 | /** |
||
34 | * Hash for anonymous user. |
||
35 | * |
||
36 | * @deprecated Use the options on UserContextSubscriber instead |
||
37 | */ |
||
38 | const ANONYMOUS_HASH = '38015b703d82206ebc01d17a39c727e5'; |
||
39 | |||
40 | /** |
||
41 | * Accept header value to be used to request the user hash to the backend application. |
||
42 | * It must match the one defined in FOSHttpCacheBundle's configuration. |
||
43 | * |
||
44 | * @deprecated Use the options on UserContextSubscriber instead |
||
45 | */ |
||
46 | const USER_HASH_ACCEPT_HEADER = 'application/vnd.fos.user-context-hash'; |
||
47 | |||
48 | /** |
||
49 | * Name of the header the user context hash will be stored into. |
||
50 | * It must match the one defined in FOSHttpCacheBundle's configuration. |
||
51 | * |
||
52 | * @deprecated Use the options on UserContextSubscriber instead |
||
53 | */ |
||
54 | const USER_HASH_HEADER = 'X-User-Context-Hash'; |
||
55 | |||
56 | /** |
||
57 | * URI used with the forwarded request for user context hash generation. |
||
58 | * |
||
59 | * @deprecated Use the options on UserContextSubscriber instead |
||
60 | */ |
||
61 | const USER_HASH_URI = '/_fos_user_context_hash'; |
||
62 | |||
63 | /** |
||
64 | * HTTP Method used with the forwarded request for user context hash generation. |
||
65 | * |
||
66 | * @deprecated Use the options on UserContextSubscriber instead |
||
67 | */ |
||
68 | const USER_HASH_METHOD = 'GET'; |
||
69 | |||
70 | /** |
||
71 | * Prefix for session names. |
||
72 | * Must match your session configuration. |
||
73 | * |
||
74 | * @deprecated Use the options on UserContextSubscriber instead |
||
75 | */ |
||
76 | const SESSION_NAME_PREFIX = 'PHPSESSID'; |
||
77 | |||
78 | /** |
||
79 | * @var UserContextSubscriber |
||
80 | */ |
||
81 | private $subscriber; |
||
82 | |||
83 | 4 | public function __construct(HttpKernelInterface $kernel, $cacheDir = null) |
|
84 | { |
||
85 | 4 | parent::__construct($kernel, $cacheDir); |
|
86 | |||
87 | 4 | $this->subscriber = new UserContextSubscriber(array( |
|
88 | 4 | 'anonymous_hash' => static::ANONYMOUS_HASH, |
|
89 | 4 | 'user_hash_accept_header' => static::USER_HASH_ACCEPT_HEADER, |
|
90 | 4 | 'user_hash_header' => static::USER_HASH_HEADER, |
|
91 | 4 | 'user_hash_uri' => static::USER_HASH_URI, |
|
92 | 4 | 'user_hash_method' => static::USER_HASH_METHOD, |
|
93 | 4 | 'session_name_prefix' => static::SESSION_NAME_PREFIX, |
|
94 | )); |
||
95 | 4 | } |
|
96 | |||
97 | 4 | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) |
|
107 | } |
||
108 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.