Redirect Block Controller view()

140 Views Asked by At

From view() of a single page controller I can redirect like following:

use \Concrete\Core\Http\ResponseFactory;
return ResponseFactory::redirect($this->getRequest()->getPathInfo());

From the view() method of a block controller the redirection with the above snippet does not work. I also tried to return the value of the AbstractController::buildRedirect() with no success.

Therefor my question is: What kind of support from c5 does exist to redierct from view() of a block controller?

1

There are 1 best solutions below

1
On BEST ANSWER

A possibility is, as I mentioned in the comment, to send the response. But then the script has to be exited to avoid rendering the view. The related snippet would be as following:

$this->app->make(ResponseFactoryInterface::class)
        ->redirect($this->getRequest()->getPathInfo())
        ->send();
exit;