Skip to content

Commit

Permalink
EZP-31086: Redirect based on router, not url alias
Browse files Browse the repository at this point in the history
  • Loading branch information
damianz5 committed Oct 29, 2019
1 parent 52578bf commit 469f3e6
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions lib/Form/Processor/SystemUrlRedirectProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

namespace EzSystems\RepositoryForms\Form\Processor;

use eZ\Publish\API\Repository\LocationService;
use eZ\Publish\API\Repository\URLAliasService;
use EzSystems\RepositoryForms\Event\FormActionEvent;
use EzSystems\RepositoryForms\Event\RepositoryFormEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand All @@ -21,26 +19,13 @@ class SystemUrlRedirectProcessor implements EventSubscriberInterface
/** @var \Symfony\Component\Routing\RouterInterface */
private $router;

/** @var \eZ\Publish\API\Repository\URLAliasService */
private $urlAliasService;

/** @var \eZ\Publish\API\Repository\LocationService */
private $locationService;

/**
* @param \Symfony\Component\Routing\RouterInterface $router
* @param \eZ\Publish\API\Repository\URLAliasService $urlAliasService
* @param \eZ\Publish\API\Repository\LocationService $locationService
* @param array $siteaccessGroups
*/
public function __construct(
RouterInterface $router,
URLAliasService $urlAliasService,
LocationService $locationService
RouterInterface $router
) {
$this->router = $router;
$this->urlAliasService = $urlAliasService;
$this->locationService = $locationService;
}

/**
Expand Down Expand Up @@ -101,8 +86,11 @@ private function resolveSystemUrlRedirect(FormActionEvent $event): void
return;
}

$location = $this->locationService->loadLocation($params['locationId']);
$url = $this->router->generate(
'_ezpublishLocation', ['locationId' => $params['locationId']]
);

$event->setResponse(new RedirectResponse($this->urlAliasService->reverseLookup($location)->path));
$event->setResponse(new RedirectResponse($url));
}
}

0 comments on commit 469f3e6

Please # to comment.