From 5291cc43b5e5307779869c70ffc1b9ea65b58552 Mon Sep 17 00:00:00 2001 From: Torben Dannhauer Date: Tue, 19 May 2026 18:02:39 +0200 Subject: [PATCH] Implement prefixSecondaryPaths method Add a method to prefix secondary route paths with a given string. --- src/RouteBuilder.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/RouteBuilder.php b/src/RouteBuilder.php index cc9ed18..d986335 100644 --- a/src/RouteBuilder.php +++ b/src/RouteBuilder.php @@ -190,6 +190,27 @@ public function withSecondaryRoute(string $path): self return $this; } + /** + * Prefix all secondary route paths (used when loading app routes under a webroot) + * + * @param string $prefix Path prefix without trailing slash (e.g. "/horde") + * @return self + */ + public function prefixSecondaryPaths(string $prefix): self + { + if ($prefix === '') { + return $this; + } + + $prefix = rtrim($prefix, '/'); + $this->secondaryPaths = array_map( + fn (string $path) => $prefix . '/' . ltrim($path, '/'), + $this->secondaryPaths + ); + + return $this; + } + /** * Set controller (PSR-style with* method) *