public function getDefaultSubscribers() { $subscribers = parent::getDefaultSubscribers(); $subscribers[] = new PurgeSubscriber(); $subscribers[] = new RefreshSubscriber(); return $subscribers; }
/** * Handle invalidation, including Http PURGE requests. * All non-allowed PURGE requests will receive an HTTP 405. * * @param \Symfony\Component\HttpFoundation\Request $request * @param bool $catch * * @return \Symfony\Component\HttpFoundation\Response */ protected function invalidate(Request $request, $catch = false) { if ($request->getMethod() !== 'PURGE' && $request->getMethod() !== 'BAN') { return parent::invalidate($request, $catch); } // Reject all non-authorized clients if (!$this->isInternalRequestAllowed($request)) { return new Response('', 405); } $response = new Response(); $store = $this->getStore(); if ($store instanceof RequestAwarePurger) { $result = $store->purgeByRequest($request); } else { $result = $store->purge($request->getUri()); } if ($result === true) { $response->setStatusCode(200, 'Purged'); } else { $response->setStatusCode(404, 'Not purged'); } return $response; }