- //Referer empty or unusable
- if (empty($referer)) {
- //Try with / path
- try {
- //Retrieve route matching /
- $route = $this->router->match('/');
-
- //Verify that it differ from current one
- if (($name = $route['_route']) == $logout) {
- throw new ResourceNotFoundException('Identical referer and logout route');
+ //With index route from config
+ if (!empty($name = $this->config['route']['index']['name']) && is_array($context = $this->config['route']['index']['context'])) {
+ //Without logout route name
+ if (($name = $route['_route']) != $logout) {
+ //Try index route
+ try {
+ //Generate url
+ $url = $this->router->generate($name, $context);
+
+ //Return generated route
+ return new RedirectResponse($url, 302);
+ //No route matched
+ } catch (ResourceNotFoundException $e) {
+ //Unset name and context
+ unset($name, $context);