compile([ 'object' => [ RouteAttribute\Object\Route::class ], 'method' => [ RouteAttribute\Method\Route::class ], ]); $crumbs = $this->compile([ 'method' => [ Attribute\Method\Breadcrumb::class ], ]); while( $route ) { $crumb = $this->getBreadcrumbAttribute($crumbs, $route); if ($crumb) { empty($tree) && $crumb->current = true; $tree[$route->name] = $crumb; $route = $this->getRouteAttribute($routes, $crumb); } else { $route = null; } } if ($this->ignoreSoleRoute && count($tree) === 1) { return []; } return array_reverse($tree); } protected function getRouteAttribute(array $list, Attribute\Method\Breadcrumb $crumb) : null|RouteAttribute\Method\Route { if ($crumb->parent ?? null) { foreach ($list as $route) { if ($crumb->parent === $route->name) { return $route; } } } return null; } protected function getBreadcrumbAttribute(array $list, RouteAttribute\Method\Route $route) : null|Attribute\Method\Breadcrumb { foreach($list as $crumb) { if ($crumb->class === $route->class && $crumb->classMethod === $route->classMethod) { $crumb->routeAnnotation = $route; return $crumb; } } return null; } }