From f8649363f92c1020e562e63f1c92508ca33a5aae Mon Sep 17 00:00:00 2001 From: luzip665 Date: Mon, 17 Jan 2022 09:15:29 +0100 Subject: [PATCH 1/5] Running xhgui from subdir --- src/Twig/TwigExtension.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Twig/TwigExtension.php b/src/Twig/TwigExtension.php index 58f3e36a..e571fd15 100755 --- a/src/Twig/TwigExtension.php +++ b/src/Twig/TwigExtension.php @@ -75,10 +75,15 @@ public function url(string $name, $queryargs = []): string $query = '?' . http_build_query($queryargs); } + $prepend = ''; + if ($this->pathPrefix !== null) { + $prepend = rtrim($this->pathPrefix, '/'); + } + // this is copy of \Slim\Slim::urlFor() // to mix path prefix in \Slim\Slim::urlFor - return rtrim($this->pathPrefix(), '/') . $this->router->urlFor($name) . $query; + return $prepend . $this->router->urlFor($name) . $query; } /** From d5d5266e611f4f78c1e5cb415a011b303d69f46a Mon Sep 17 00:00:00 2001 From: luzip665 Date: Mon, 17 Jan 2022 11:04:37 +0100 Subject: [PATCH 2/5] Running xhgui from subdir --- src/Twig/TwigExtension.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Twig/TwigExtension.php b/src/Twig/TwigExtension.php index e571fd15..a6630a3f 100755 --- a/src/Twig/TwigExtension.php +++ b/src/Twig/TwigExtension.php @@ -12,7 +12,7 @@ class TwigExtension extends AbstractExtension { /** @var Router */ private $router; - /** @var string|null */ + /** @var string */ private $pathPrefix; /** @var Request */ private $request; @@ -21,6 +21,9 @@ public function __construct(Router $router, Request $request, ?string $pathPrefi { $this->router = $router; $this->request = $request; + if (!$pathPrefix) { + $pathPrefix = ''; + } $this->pathPrefix = $pathPrefix; } @@ -75,15 +78,10 @@ public function url(string $name, $queryargs = []): string $query = '?' . http_build_query($queryargs); } - $prepend = ''; - if ($this->pathPrefix !== null) { - $prepend = rtrim($this->pathPrefix, '/'); - } - // this is copy of \Slim\Slim::urlFor() // to mix path prefix in \Slim\Slim::urlFor - return $prepend . $this->router->urlFor($name) . $query; + return rtrim($this->pathPrefix, '/') . $this->router->urlFor($name) . $query; } /** From 276a2556bc43afb3b2ba24b6854478412202a93c Mon Sep 17 00:00:00 2001 From: luzip665 Date: Mon, 17 Jan 2022 11:31:02 +0100 Subject: [PATCH 3/5] Running xhgui from subdir --- src/Twig/TwigExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Twig/TwigExtension.php b/src/Twig/TwigExtension.php index a6630a3f..2cdac13e 100755 --- a/src/Twig/TwigExtension.php +++ b/src/Twig/TwigExtension.php @@ -135,7 +135,7 @@ public function formatPercent($value): string private function pathPrefix(): string { - if ($this->pathPrefix !== null) { + if ($this->pathPrefix !== '') { return $this->pathPrefix; } From cfc60228cf0d014a653a4643f43ba9d52e3315ba Mon Sep 17 00:00:00 2001 From: luzip665 Date: Mon, 17 Jan 2022 15:04:27 +0100 Subject: [PATCH 4/5] Running xhgui from subdir --- src/Twig/TwigExtension.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Twig/TwigExtension.php b/src/Twig/TwigExtension.php index 2cdac13e..322414ee 100755 --- a/src/Twig/TwigExtension.php +++ b/src/Twig/TwigExtension.php @@ -21,9 +21,6 @@ public function __construct(Router $router, Request $request, ?string $pathPrefi { $this->router = $router; $this->request = $request; - if (!$pathPrefix) { - $pathPrefix = ''; - } $this->pathPrefix = $pathPrefix; } @@ -81,7 +78,9 @@ public function url(string $name, $queryargs = []): string // this is copy of \Slim\Slim::urlFor() // to mix path prefix in \Slim\Slim::urlFor - return rtrim($this->pathPrefix, '/') . $this->router->urlFor($name) . $query; + $prepend = $this->pathPrefix ?: ''; + + return rtrim($prepend, '/') . $this->router->urlFor($name) . $query; } /** @@ -135,7 +134,7 @@ public function formatPercent($value): string private function pathPrefix(): string { - if ($this->pathPrefix !== '') { + if ($this->pathPrefix !== null) { return $this->pathPrefix; } From 4e051465ec2a5fc9d6a296cab24026ea8bdc72cd Mon Sep 17 00:00:00 2001 From: luzip665 Date: Mon, 17 Jan 2022 15:46:33 +0100 Subject: [PATCH 5/5] Running xhgui from subdir --- src/Twig/TwigExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Twig/TwigExtension.php b/src/Twig/TwigExtension.php index 322414ee..11db9cc7 100755 --- a/src/Twig/TwigExtension.php +++ b/src/Twig/TwigExtension.php @@ -12,7 +12,7 @@ class TwigExtension extends AbstractExtension { /** @var Router */ private $router; - /** @var string */ + /** @var string|null */ private $pathPrefix; /** @var Request */ private $request;