- Added a new getRoute() method
This commit is contained in:
parent
85db84e057
commit
3f8f24a35f
|
@ -16,6 +16,8 @@ class Route implements \Notes\Annotation {
|
|||
|
||||
public string $method;
|
||||
|
||||
public string $base;
|
||||
|
||||
public array $methods;
|
||||
|
||||
public string $class;
|
||||
|
@ -36,4 +38,12 @@ class Route implements \Notes\Annotation {
|
|||
$this->method = $method;
|
||||
}
|
||||
}
|
||||
|
||||
public function getRoute() : string
|
||||
{
|
||||
return "/" . trim(isset($this->base) ?
|
||||
"/" . trim($this->base, "/") . "/" . ltrim($this->route, "/")
|
||||
:
|
||||
"/" . ltrim($this->route, "/"), "/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ class Route implements \Notes\Annotation {
|
|||
|
||||
public array $methods;
|
||||
|
||||
public string $base = "";
|
||||
|
||||
public function __construct(?array $methods = null)
|
||||
{
|
||||
if ( $methods !== null ) {
|
||||
|
|
|
@ -64,6 +64,7 @@ class RouteFetcher {
|
|||
public function compile() : Generator
|
||||
{
|
||||
foreach($this->scan() as $namespace => $file) {
|
||||
$base = "";
|
||||
$class = $this->generateClassname($file->getBasename(".php"), $namespace);
|
||||
$methods = $this->defaultMethods;
|
||||
|
||||
|
@ -74,11 +75,15 @@ class RouteFetcher {
|
|||
if ( $object->methods ?? false ) {
|
||||
$methods = $object->methods;
|
||||
}
|
||||
|
||||
$base = $object->base ?? "";
|
||||
}
|
||||
|
||||
$routeList = $objectResolver->getAnnotationListFromClassname( $this->annotations['method'] );
|
||||
|
||||
foreach($routeList as $func => $route) {
|
||||
|
||||
$route->base = $base;
|
||||
$route->class = $class;
|
||||
$route->classMethod = $func;
|
||||
|
||||
|
|
Loading…
Reference in New Issue