Can symfony just reload the page request?

I have an application that receives a request from another application. It detects the value in the query string, checks this value for the cache value and, if they do not match, it needs to clear its cache and reload the page (by setting a new cache). Unfortunately, I cannot 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? All this happens in the filter on isFirstCall() .

Thanks.

+4
source share
2 answers

We did it in the filter.

A bit hacky, but here's an example of doing redirects in a filter ... you have to do a cache check 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(); } } 
+4
source

If you want to redirect, you can do the following:

 if (true===$redirect) { return $this->getContext()->getController()->redirect($request->getUri()); } 
+1
source

Source: https://habr.com/ru/post/1312792/


All Articles