@@ -416,36 +416,35 @@ public static function controller(string $url, string $controller, array $settin
416
416
417
417
public static function loadRoutes (string $ controller )
418
418
{
419
- $ group = new RouteGroup ();
419
+ $ group_settings = array ();
420
+ $ group_prefix = '' ;
420
421
421
422
$ class = new \ReflectionClass ($ controller );
422
423
$ attributes = $ class ->getAttributes (\Pecee \Http \Input \Attributes \RouteGroup::class);
423
424
if (sizeof ($ attributes ) > 0 ){
424
425
/**
425
- * @var $attribute RouteGroup
426
+ * @var $attribute \Pecee\Http\Input\Attributes\ RouteGroup
426
427
*/
427
428
$ attribute = $ attributes [0 ]->newInstance ();
428
- $ group ->setPrefix ($ attribute ->getRoute ());
429
- if ($ attribute ->getSettings () !== null )
430
- $ group ->setSettings ($ attribute ->getSettings ());
429
+ $ group_prefix = $ attribute ->getRoute ();
430
+ $ group_settings = $ attribute ->getSettings () ?? array ();
431
431
}
432
432
433
433
foreach ($ class ->getMethods () as $ method ){
434
434
$ attributes = $ method ->getAttributes (\Pecee \Http \Input \Attributes \Route::class);
435
435
foreach ($ attributes as $ attribute ){
436
436
/**
437
- * @var $attribute_attr Route
437
+ * @var $attribute_attr \Pecee\Http\Input\Attributes\ Route
438
438
*/
439
439
$ attribute_attr = $ attribute ->newInstance ();
440
+ error_log (json_encode ($ group_prefix . $ attribute_attr ->getRoute () . '- ' . $ attribute_attr ->getMethod () . '- ' . $ class ->getNamespaceName () . $ class ->getShortName () . '- ' . $ method ->getName ()));
440
441
441
- $ route = new RouteUrl ($ attribute_attr ->getRoute (), sprintf ('%s@%s ' , $ class ->getName (), $ method ->getName ()));
442
+ $ route = new RouteUrl ($ group_prefix . $ attribute_attr ->getRoute (), sprintf ('%s@%s ' , '\\' . $ class ->getName (), $ method ->getName ()));
442
443
$ route ->setRequestMethods ([$ attribute_attr ->getMethod ()]);
443
- if ($ attribute_attr ->getSettings () !== null )
444
- $ route ->setSettings ($ attribute_attr ->getSettings ());
445
- $ route ->setGroup ($ group );
444
+ $ route ->setSettings (array_merge ($ attribute_attr ->getSettings () ?? array (), $ group_settings ));
445
+
446
446
static ::router ()->addRoute ($ route );
447
447
}
448
-
449
448
}
450
449
}
451
450
0 commit comments