Skip to content

Commit

Permalink
set contao environment request url to referrer in ajax calls
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Oct 25, 2019
1 parent 5c53804 commit 2fd52ed
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Controller/FrontendAjaxController.php
Expand Up @@ -8,11 +8,13 @@

namespace HeimrichHannot\FilterBundle\Controller;

use Contao\Environment;
use Contao\FrontendIndex;
use Contao\System;
use HeimrichHannot\FilterBundle\Event\ModifyJsonResponseEvent;
use HeimrichHannot\FilterBundle\Exception\HandleFormException;
use HeimrichHannot\FilterBundle\Exception\MissingFilterException;
use HeimrichHannot\FilterBundle\Form\FilterType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -48,6 +50,9 @@ public function ajaxSubmitAction(Request $request, int $id): Response
if (null === ($response = $filter->handleForm())) {
throw new HandleFormException('Unable to handle form for filter with id '.$id.'.');
}
if ($request->get($filter->getFilter()['name']) && isset($request->get($filter->getFilter()['name'])[FilterType::FILTER_REFERRER_NAME])) {
Environment::set('request', $request->get($filter->getFilter()['name'])[FilterType::FILTER_REFERRER_NAME]);
}

$index = new FrontendIndex(); // initialize BE_USER_LOGGED_IN or FE_USER_LOGGED_IN

Expand Down

0 comments on commit 2fd52ed

Please sign in to comment.