D8 - Programmatically Redirect in Custom module


Use the below code

use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Url;

return new RedirectResponse(\Drupal::url('{route_name}'));


{route_name} - Name given while defining the path in .routing file.

To derive the route_name of a views created page refer the below link,
http://romelchrist.blogspot.com/2017/09/d8-derive-routename-for-views-created.html


Comments

Popular posts from this blog

PHP - How to increase size of POST value in php

D8 KernelEvents constants

D8 - Attach file programmatically to a node