From 90aba46351cf08546f83a697848e7233405edfc9 Mon Sep 17 00:00:00 2001 From: Giso Stallenberg Date: Wed, 15 Jul 2020 14:49:55 +0200 Subject: [PATCH] Remove the need for League Uri (#184) Remove the need for League Uri --- composer.json | 2 -- src/Controller/AdminExtensionControllerTrait.php | 10 ++++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index b1dbaaf..e5912a2 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,6 @@ "doctrine/doctrine-bundle": "^1.8|^2.0", "doctrine/orm": "^2.6", "easycorp/easyadmin-bundle": "^2.2.2", - "league/uri-manipulations": "^1.3", - "league/uri-schemes": "^1.2", "symfony/config": "^4.2|^5.0", "symfony/dependency-injection": "^4.2|^5.0", "symfony/event-dispatcher": "^4.2|^5.0", diff --git a/src/Controller/AdminExtensionControllerTrait.php b/src/Controller/AdminExtensionControllerTrait.php index a9c6551..4a8f093 100644 --- a/src/Controller/AdminExtensionControllerTrait.php +++ b/src/Controller/AdminExtensionControllerTrait.php @@ -4,8 +4,6 @@ use AlterPHP\EasyAdminExtensionBundle\Security\AdminAuthorizationChecker; use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; -use League\Uri\Modifiers\RemoveQueryParams; -use League\Uri\Schemes\Http; use Symfony\Component\HttpFoundation\JsonResponse; trait AdminExtensionControllerTrait @@ -34,12 +32,12 @@ function ($name) use ($hiddenFields) { $baseMasterRequestUri = !$this->request->isXmlHttpRequest() ? $this->get('request_stack')->getMasterRequest()->getUri() : $this->request->headers->get('referer'); - $baseMasterRequestUri = Http::createFromString($baseMasterRequestUri); - $removeRefererModifier = new RemoveQueryParams(['referer']); - $masterRequestUri = $removeRefererModifier->process($baseMasterRequestUri); + \parse_str(\parse_url($baseMasterRequestUri, PHP_URL_QUERY), $queryParameters); + unset($queryParameters['referer']); + $masterRequestUri = \sprintf('%s?%s', \strtok($baseMasterRequestUri, '?'), \http_build_query($queryParameters)); $requestParameters = $this->request->query->all(); - $requestParameters['referer'] = (string) $masterRequestUri; + $requestParameters['referer'] = $masterRequestUri; $viewVars = [ 'paginator' => $paginator,