- Working on removing annotations for attributes
This commit is contained in:
parent
c4f303434d
commit
ad7708f487
|
@ -3,20 +3,20 @@
|
||||||
use Notes\ObjectReflection,
|
use Notes\ObjectReflection,
|
||||||
Notes\ObjectResolver;
|
Notes\ObjectResolver;
|
||||||
|
|
||||||
use Notes\Route\{ RouteFetcher, Annotation as RouteAnnotation };
|
use Notes\Route\{ RouteFetcher, Attribute as RouteAttribute };
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Psr\SimpleCache\CacheInterface;
|
use Psr\SimpleCache\CacheInterface;
|
||||||
use RuntimeException, DirectoryIterator, Generator;
|
use RuntimeException, DirectoryIterator, Generator;
|
||||||
|
|
||||||
class Breadcrumb extends RouteFetcher {
|
class Breadcrumb extends RouteFetcher {
|
||||||
|
|
||||||
public function getRouteTree(RouteAnnotation\Method\Route|\Notes\Route\Attribute\Method\Route $route) : array
|
public function getRouteTree(\Notes\Route\Attribute\Method\Route $route) : array
|
||||||
{
|
{
|
||||||
$tree = [];
|
$tree = [];
|
||||||
|
|
||||||
$routes = $this->compile([
|
$routes = $this->compile([
|
||||||
'object' => [ RouteAnnotation\Object\Route::class, Attribute\Object\Route::class ],
|
'object' => [ RouteAttribute\Object\Route::class ],
|
||||||
'method' => [ RouteAnnotation\Method\Route::class ],
|
'method' => [ RouteAttribute\Method\Route::class ],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$crumbs = $this->compile([
|
$crumbs = $this->compile([
|
||||||
|
@ -24,14 +24,14 @@ class Breadcrumb extends RouteFetcher {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
while( $route ) {
|
while( $route ) {
|
||||||
$crumb = $this->getBreadcrumbAnnotation($crumbs, $route);
|
$crumb = $this->getBreadcrumbAttribute($crumbs, $route);
|
||||||
|
|
||||||
if ($crumb) {
|
if ($crumb) {
|
||||||
empty($tree) && $crumb->current = true;
|
empty($tree) && $crumb->current = true;
|
||||||
|
|
||||||
$tree[$route->name] = $crumb;
|
$tree[$route->name] = $crumb;
|
||||||
|
|
||||||
$route = $this->getRouteAnnotation($routes, $crumb);
|
$route = $this->getRouteAttribute($routes, $crumb);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$route = null;
|
$route = null;
|
||||||
|
@ -41,7 +41,7 @@ class Breadcrumb extends RouteFetcher {
|
||||||
return array_reverse($tree);
|
return array_reverse($tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getRouteAnnotation(array $list, Annotation\Method\Breadcrumb|Attribute\Method\Breadcrumb $crumb) : null|RouteAnnotation\Method\Route|\Notes\Route\Attribute\Method\Route
|
protected function getRouteAttribute(array $list, Attribute\Method\Breadcrumb $crumb) : null|RouteAttribute\Method\Route
|
||||||
{
|
{
|
||||||
if ($crumb->parent ?? null) {
|
if ($crumb->parent ?? null) {
|
||||||
foreach ($list as $route) {
|
foreach ($list as $route) {
|
||||||
|
@ -54,7 +54,7 @@ class Breadcrumb extends RouteFetcher {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getBreadcrumbAnnotation(array $list, RouteAnnotation\Method\Route|\Notes\Route\Attribute\Method\Route $route) : null|Annotation\Method\Breadcrumb|Attribute\Method\Breadcrumb
|
protected function getBreadcrumbAttribute(array $list, RouteAttribute\Method\Route $route) : null|Attribute\Method\Breadcrumb
|
||||||
{
|
{
|
||||||
foreach($list as $crumb) {
|
foreach($list as $crumb) {
|
||||||
if ($crumb->class === $route->class && $crumb->classMethod === $route->classMethod) {
|
if ($crumb->class === $route->class && $crumb->classMethod === $route->classMethod) {
|
||||||
|
|
Loading…
Reference in New Issue