1 | <?php |
||
43 | trait EventDispatchingHttpCache |
||
44 | { |
||
45 | /** |
||
46 | * @var EventDispatcherInterface |
||
47 | */ |
||
48 | private $eventDispatcher; |
||
49 | |||
50 | /** |
||
51 | * Get event dispatcher. |
||
52 | * |
||
53 | * @return EventDispatcherInterface |
||
54 | */ |
||
55 | 9 | public function getEventDispatcher() |
|
63 | |||
64 | /** |
||
65 | * Add an event subscriber. |
||
66 | * |
||
67 | * @see EventDispatcherInterface::addSubscriber |
||
68 | */ |
||
69 | 9 | public function addSubscriber(EventSubscriberInterface $subscriber) |
|
73 | |||
74 | /** |
||
75 | * Add an event listener to this HttpCache. |
||
76 | * |
||
77 | * @see EventDispatcherInterface::addListener |
||
78 | */ |
||
79 | 5 | public function addListener($eventName, $listener, $priority = 0) |
|
83 | |||
84 | 5 | /** |
|
85 | 2 | * {@inheritdoc} |
|
86 | * |
||
87 | * Adding the Events::PRE_HANDLE and Events::POST_HANDLE events. |
||
88 | 3 | */ |
|
89 | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) |
||
102 | 2 | ||
103 | 2 | /** |
|
104 | * {@inheritdoc} |
||
105 | * |
||
106 | * Trigger event to alter response before storing it in the cache. |
||
107 | */ |
||
108 | protected function store(Request $request, Response $response) |
||
114 | |||
115 | /** |
||
116 | 1 | * {@inheritdoc} |
|
117 | * |
||
118 | * Adding the Events::PRE_INVALIDATE event. |
||
119 | */ |
||
120 | protected function invalidate(Request $request, $catch = false) |
||
128 | 9 | ||
129 | /** |
||
130 | 9 | * Dispatch an event if needed. |
|
131 | 9 | * |
|
132 | 9 | * @param string $name Name of the event to trigger. One of the constants in FOS\HttpCache\SymfonyCache\Events |
|
133 | 9 | * @param Request $request |
|
134 | 9 | * @param Response|null $response If already available |
|
135 | * |
||
136 | 9 | * @return Response The response to return, which might be provided/altered by a listener |
|
137 | */ |
||
138 | protected function dispatch($name, Request $request, Response $response = null) |
||
148 | } |
||
149 |