From e1b0b5bb6256badd24343c48bb59803e56a0c9be Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 8 Feb 2024 18:00:18 +0100 Subject: [PATCH 01/24] Add HydeKernel property for the main NavigationMenu --- packages/framework/src/Foundation/HydeKernel.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/src/Foundation/HydeKernel.php b/packages/framework/src/Foundation/HydeKernel.php index a476090bfc5..1104d216067 100644 --- a/packages/framework/src/Foundation/HydeKernel.php +++ b/packages/framework/src/Foundation/HydeKernel.php @@ -13,6 +13,7 @@ use Hyde\Support\Contracts\SerializableContract; use Hyde\Support\Concerns\Serializable; use Illuminate\Support\Traits\Macroable; +use Hyde\Framework\Features\Navigation\NavigationMenu; /** * Encapsulates a HydePHP project, providing helpful methods for interacting with it. @@ -65,6 +66,8 @@ class HydeKernel implements SerializableContract protected PageCollection $pages; protected RouteCollection $routes; + protected NavigationMenu $navigation; + protected bool $booted = false; /** @var array, \Hyde\Foundation\Concerns\HydeExtension> */ From 1b577c98b17d1706d6af720a40383b476c0e2561 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 8 Feb 2024 18:01:05 +0100 Subject: [PATCH 02/24] Create navigation menu on kernel boot --- packages/framework/src/Foundation/Concerns/BootsHydeKernel.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/src/Foundation/Concerns/BootsHydeKernel.php b/packages/framework/src/Foundation/Concerns/BootsHydeKernel.php index c680133cc9f..76ded9e4742 100644 --- a/packages/framework/src/Foundation/Concerns/BootsHydeKernel.php +++ b/packages/framework/src/Foundation/Concerns/BootsHydeKernel.php @@ -7,6 +7,7 @@ use Hyde\Foundation\Kernel\FileCollection; use Hyde\Foundation\Kernel\PageCollection; use Hyde\Foundation\Kernel\RouteCollection; +use Hyde\Framework\Features\Navigation\NavigationMenu; /** * @internal Single-use trait for the HydeKernel class. @@ -58,6 +59,8 @@ public function boot(): void $callback($this); } + $this->navigation = NavigationMenu::create(); + $this->booting = false; $this->booted = true; } From ad16097f4a8bcaa8976b51de179ec9f30e5695d7 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 8 Feb 2024 18:05:37 +0100 Subject: [PATCH 03/24] Add kernel navigation accessor --- packages/framework/src/Foundation/HydeKernel.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/framework/src/Foundation/HydeKernel.php b/packages/framework/src/Foundation/HydeKernel.php index 1104d216067..cb6097a30cf 100644 --- a/packages/framework/src/Foundation/HydeKernel.php +++ b/packages/framework/src/Foundation/HydeKernel.php @@ -112,4 +112,9 @@ public function toArray(): array 'routes' => $this->routes(), ]; } + + public function navigation(): NavigationMenu + { + return $this->navigation; + } } From a5ed6cb0aaddedf3ac04cf1e2f0c349e9abdbd1b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 8 Feb 2024 18:05:56 +0100 Subject: [PATCH 04/24] Get navigation from kernel --- packages/framework/resources/views/layouts/navigation.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/resources/views/layouts/navigation.blade.php b/packages/framework/resources/views/layouts/navigation.blade.php index 17707d5e10a..cf8c2954bab 100644 --- a/packages/framework/resources/views/layouts/navigation.blade.php +++ b/packages/framework/resources/views/layouts/navigation.blade.php @@ -1,5 +1,5 @@ @php - $navigation = \Hyde\Framework\Features\Navigation\NavigationMenu::create(); + $navigation = \Hyde\Hyde::navigation(); @endphp