Skip to content

Commit 9ec02b1

Browse files
committed
Change RouterService to use a route group for profile URLs.
1 parent 86a5ffe commit 9ec02b1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Service/RouterService.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Pdsinterop\Solid\Service;
44

55
use League\Container\Container;
6+
use League\Route\RouteGroup;
67
use League\Route\Router;
78
use League\Route\Strategy\ApplicationStrategy;
89
use Pdsinterop\Solid\Controller\AddSlashToPathController;
@@ -47,18 +48,20 @@ final public function populate() : Router
4748

4849
/*/ Map routes and groups /*/
4950
$router->map('GET', '/', HelloWorldController::class)->setScheme($scheme);
50-
$this->mapProfile($router, $scheme);
51+
$router->group('/profile', $this->createProfileGroup())->setScheme($scheme);
5152

5253
return $router;
5354
}
5455

5556
////////////////////////////// UTILITY METHODS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
5657

57-
private function mapProfile(Router $router, string $scheme) : void
58+
private function createProfileGroup() : Callable
5859
{
59-
$router->map('GET', '/profile', AddSlashToPathController::class)->setScheme($scheme);
60-
$router->map('GET', '/profile/', ProfileController::class)->setScheme($scheme);
61-
$router->map('GET', '/profile/card', CardController::class)->setScheme($scheme);
62-
$router->map('GET', '/profile/card{extension}', CardController::class)->setScheme($scheme);
60+
return static function (RouteGroup $group) {
61+
$group->map('GET', '/', AddSlashToPathController::class);
62+
$group->map('GET', '', ProfileController::class);
63+
$group->map('GET', '/card', CardController::class);
64+
$group->map('GET', '/card{extension}', CardController::class);
65+
};
6366
}
6467
}

0 commit comments

Comments
 (0)