feat: remove easy admin bundle, adopt admin theme
This commit is contained in:
1 parent
52ee6b26b1
commit
2fc7ffe458
52 files changed
+1947
-690
No files matched your search
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Traits;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
trait ReturnUrlTrait
|
||||
{
|
||||
public function getReturnUrl(Request $request, string $defaultRoute, array $parameters = []): string
|
||||
{
|
||||
$defaultUrl = $this->generateUrl($defaultRoute, $parameters);
|
||||
|
||||
return rawurldecode($request->query->get('r', $defaultUrl));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove specified query parameters from a URL.
|
||||
*
|
||||
* @param string $url The URL to process
|
||||
* @param string[] $parametersKeys Array of query parameter keys to remove
|
||||
*
|
||||
* @return string The URL without the specified query parameters
|
||||
*/
|
||||
public function removeQueryParameters(string $url, array $parametersKeys): string
|
||||
{
|
||||
if ([] === $parametersKeys) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
$urlParts = parse_url($url);
|
||||
|
||||
if (false === isset($urlParts['query'])) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
parse_str($urlParts['query'], $queryParams);
|
||||
|
||||
foreach ($parametersKeys as $key) {
|
||||
unset($queryParams[$key]);
|
||||
}
|
||||
|
||||
$urlParts['query'] = http_build_query($queryParams);
|
||||
|
||||
if ('' === $urlParts['query']) {
|
||||
unset($urlParts['query']);
|
||||
}
|
||||
|
||||
// Rebuild URL
|
||||
$result = '';
|
||||
if (isset($urlParts['scheme'])) {
|
||||
$result .= $urlParts['scheme'].'://';
|
||||
}
|
||||
if (isset($urlParts['host'])) {
|
||||
$result .= $urlParts['host'];
|
||||
}
|
||||
if (isset($urlParts['port'])) {
|
||||
$result .= ':'.$urlParts['port'];
|
||||
}
|
||||
if (isset($urlParts['path'])) {
|
||||
$result .= $urlParts['path'];
|
||||
}
|
||||
if (isset($urlParts['query'])) {
|
||||
$result .= '?'.$urlParts['query'];
|
||||
}
|
||||
if (isset($urlParts['fragment'])) {
|
||||
$result .= '#'.$urlParts['fragment'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user