diff --git a/src/Route.php b/src/Route.php index c71f7f4b..78b3f3ca 100644 --- a/src/Route.php +++ b/src/Route.php @@ -19,8 +19,19 @@ final class Route if (!preg_match($this->regex, $query, $matches)) return false; $routeArguments = $this->getRouteArguments($matches); + $func = $this->route; - $output = $func(...array_values($routeArguments)); + if (is_array($this->route) && $this->route[1] === 'work') + { + foreach ($matches as $key => $value) + $this->route[0]->setArgument($key, $value); + $output = $func(); + } + else + { + $output = $func(...array_values($routeArguments)); + } + return true; } diff --git a/src/Routes/AbstractRoute.php b/src/Routes/AbstractRoute.php index efae6d59..03db8ac8 100644 --- a/src/Routes/AbstractRoute.php +++ b/src/Routes/AbstractRoute.php @@ -3,9 +3,21 @@ namespace Szurubooru\Routes; abstract class AbstractRoute { + protected $arguments = []; + public abstract function getMethods(); public abstract function getUrl(); public abstract function work(); + + public function setArgument($argName, $argValue) + { + $this->arguments[$argName] = $argValue; + } + + protected function getArgument($argName) + { + return $this->arguments[$argName]; + } }