/** * {@inheritdoc} */ public function clear() { if ($this->proxyClient instanceof BanInterface) { $request = $this->requestStack->getCurrentRequest(); if (!$request) { return; } $this->proxyClient->banPath(BanInterface::REGEX_MATCH_ALL, BanInterface::CONTENT_TYPE_ALL, [$request->getHost()]); return $this->proxyClient->flush(); } $path = sprintf('%s/cache/website/%s/http_cache', $this->varDir ?: $this->kernelRootDir, $this->kernelEnvironment); if ($this->filesystem->exists($path)) { $this->filesystem->remove($path); } }
/** * Invalidate URLs based on a regular expression for the URI, an optional * content type and optional limit to certain hosts. * * The hosts parameter can either be a regular expression, e.g. * '^(www\.)?(this|that)\.com$' or an array of exact host names, e.g. * ['example.com', 'other.net']. If the parameter is empty, all hosts * are matched. * * @see BanInterface::banPath() * * @param string $path Regular expression pattern for URI to * invalidate. * @param string $contentType Regular expression pattern for the content * type to limit banning, for instance 'text'. * @param array|string $hosts Regular expression of a host name or list of * exact host names to limit banning. * * @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests * * @return $this */ public function invalidateRegex($path, $contentType = null, $hosts = null) { if (!$this->cache instanceof BanInterface) { throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN'); } $this->cache->banPath($path, $contentType, $hosts); return $this; }