1 | <?php |
||
18 | class CacheListener extends AbstractListenerAggregate |
||
19 | { |
||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $listeners = array(); |
||
24 | |||
25 | /** |
||
26 | * @var CacheService |
||
27 | */ |
||
28 | protected $cacheService; |
||
29 | |||
30 | /** |
||
31 | * @var ModuleOptions |
||
32 | */ |
||
33 | protected $options; |
||
34 | |||
35 | /** |
||
36 | * @var bool |
||
37 | */ |
||
38 | protected $loadedFromCache = false; |
||
39 | |||
40 | /** |
||
41 | * Default constructor |
||
42 | * |
||
43 | * @param CacheService $cacheService |
||
44 | * @param ModuleOptions $options |
||
45 | */ |
||
46 | public function __construct(CacheService $cacheService, ModuleOptions $options) |
||
51 | |||
52 | /** |
||
53 | * {@inheritDoc} |
||
54 | */ |
||
55 | public function attach(EventManagerInterface $events, $priority = 1) |
||
60 | |||
61 | /** |
||
62 | * Load the page contents from the cache and set the response. |
||
63 | * |
||
64 | * @param MvcEvent $e |
||
65 | * @return HttpResponse |
||
66 | */ |
||
67 | public function onRoute(MvcEvent $e) |
||
95 | |||
96 | /** |
||
97 | * @param HttpResponse $response |
||
98 | * @param string $value |
||
99 | */ |
||
100 | private function addDebugResponseHeader(HttpResponse $response, $value) |
||
106 | |||
107 | /** |
||
108 | * Save page contents to the cache |
||
109 | * |
||
110 | * @param MvcEvent $e |
||
111 | * @return void |
||
112 | */ |
||
113 | public function onFinish(MvcEvent $e) |
||
121 | |||
122 | /** |
||
123 | * @return CacheService |
||
124 | */ |
||
125 | public function getCacheService() |
||
129 | |||
130 | /** |
||
131 | * @return ModuleOptions |
||
132 | */ |
||
133 | public function getOptions() |
||
137 | } |
||
138 |