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) *