- Work mostly completed, some more test to be done (like possible recursion to avoid), but still working
This commit is contained in:
parent
eed3c693c7
commit
4549d93583
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Notes\Breadcrumb\Attribute\Method;
|
||||
|
||||
#[\Attribute]
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
|
||||
class Breadcrumb implements \Notes\Attribute {
|
||||
|
||||
public Route $routeAnnotation;
|
||||
|
|
|
@ -3,24 +3,24 @@
|
|||
use Notes\ObjectReflection,
|
||||
Notes\ObjectResolver;
|
||||
|
||||
use Notes\Route\RouteFetcher;
|
||||
use Notes\Route\{ RouteFetcher, Annotation as RouteAnnotation };
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use RuntimeException, DirectoryIterator, Generator;
|
||||
|
||||
class Breadcrumb extends RouteFetcher {
|
||||
|
||||
public function getRouteTree(\Notes\Route\Annotation\Method\Route $route) : array
|
||||
public function getRouteTree(RouteAnnotation\Method\Route|\Notes\Route\Attribute\Method\Route $route) : array
|
||||
{
|
||||
$tree = [];
|
||||
|
||||
$routes = $this->compile([
|
||||
'object' => [ Annotation\Object\Route::class, Attribute\Object\Route::class ],
|
||||
'method' => [ Annotation\Method\Route::class ],
|
||||
'object' => [ RouteAnnotation\Object\Route::class, Attribute\Object\Route::class ],
|
||||
'method' => [ RouteAnnotation\Method\Route::class ],
|
||||
]);
|
||||
|
||||
$crumbs = $this->compile([
|
||||
'method' => [ Annotation\Method\Breadcrumb::class, Attribute\Method\Breadcrumb::class ],
|
||||
'method' => [ Attribute\Method\Breadcrumb::class ],
|
||||
]);
|
||||
|
||||
while( $route ) {
|
||||
|
@ -41,7 +41,7 @@ class Breadcrumb extends RouteFetcher {
|
|||
return array_reverse($tree);
|
||||
}
|
||||
|
||||
protected function getRouteAnnotation(array $list, Annotation\Method\Breadcrumb $crumb) : null|\Notes\Route\Annotation\Method\Route
|
||||
protected function getRouteAnnotation(array $list, Annotation\Method\Breadcrumb|Attribute\Method\Breadcrumb $crumb) : null|RouteAnnotation\Method\Route|\Notes\Route\Attribute\Method\Route
|
||||
{
|
||||
if ($crumb->parent ?? null) {
|
||||
foreach ($list as $route) {
|
||||
|
@ -54,7 +54,7 @@ class Breadcrumb extends RouteFetcher {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected function getBreadcrumbAnnotation(array $list, \Notes\Route\Annotation\Method\Route $route) : null|Annotation\Method\Breadcrumb
|
||||
protected function getBreadcrumbAnnotation(array $list, RouteAnnotation\Method\Route|\Notes\Route\Attribute\Method\Route $route) : null|Annotation\Method\Breadcrumb|Attribute\Method\Breadcrumb
|
||||
{
|
||||
foreach($list as $crumb) {
|
||||
if ($crumb->class === $route->class && $crumb->classMethod === $route->classMethod) {
|
||||
|
|
Loading…
Reference in New Issue