Reputation: 41236
I have an app that receives a request from another app. It detects a value on the query string, checks that value against a cached value and, if they don't match, it needs to clear its cache and reload the page (establishing a new cache). Unfortunately, I can't find a way to tell Symfony to redirect to the current page in exactly the same format (protocol, URI path, query string, etc.). What am I missing? This is all happening in a filter on isFirstCall()
.
Thanks.
Upvotes: 4
Views: 7404
Reputation: 24897
If you want to redirect, you can do like this:
if (true===$redirect)
{
return $this->getContext()->getController()->redirect($request->getUri());
}
Upvotes: 1
Reputation: 1901
We have done this in a filter.
It is a bit hacky but here is an example of doing the redirect in a filter...you'll have to do the testing of the cache yourself...
class invalidateCacheFilter extends sfFilter {
public function execute($filterChain) {
$redirect=true;
if($redirect===true)
{
$request = $this->getContext()->getRequest();
/**
This is the hacky bit. I am pretty sure we can do this in the request object,
but we needed to get it done quickly and this is exactly what needed to happen.
*/
header("location: ".$request->getUri());
exit();
}
$filterChain->execute();
}
}
Upvotes: 4