1 | <?php |
||
19 | class CacheListener implements ListenerAggregateInterface |
||
20 | { |
||
21 | /** |
||
22 | * |
||
23 | * @var StorageInterface |
||
24 | */ |
||
25 | private $cache; |
||
26 | |||
27 | /** |
||
28 | * @var callable[] |
||
29 | */ |
||
30 | protected $listeners = array(); |
||
31 | |||
32 | /** |
||
33 | * {@inheritDoc} |
||
34 | */ |
||
35 | 1 | public function detach(EventManagerInterface $events) |
|
36 | { |
||
37 | 1 | foreach ($this->listeners as $index => $callback) { |
|
38 | 1 | $events->detach($callback); |
|
39 | 1 | unset($this->listeners[$index]); |
|
40 | } |
||
41 | 1 | } |
|
42 | |||
43 | 2 | public function __construct(StorageInterface $cache) |
|
47 | |||
48 | /** |
||
49 | * @param EventManagerInterface $events |
||
50 | * @param int $priority |
||
51 | */ |
||
52 | 1 | public function attach(EventManagerInterface $events, $priority = 1) |
|
57 | |||
58 | /** |
||
59 | * Searches the cache for rendered markdown. |
||
60 | * |
||
61 | * @param \Zend\EventManager\Event $event |
||
62 | * @return mixed the rendered markdown, if found, false otherwise |
||
63 | * @throws \Zend\Cache\Exception\ExceptionInterface |
||
64 | */ |
||
65 | 1 | public function preRender(Event $event) |
|
81 | |||
82 | /** |
||
83 | * Saves the rendered markdown within the cache. |
||
84 | * |
||
85 | * @param \Zend\EventManager\Event $event |
||
86 | * @return mixed |
||
87 | * @throws \Zend\Cache\Exception\ExceptionInterface |
||
88 | */ |
||
89 | 1 | public function postRender(Event $event) |
|
98 | } |
||
99 |