Skip to content

Commit

Permalink
Merge pull request #205 from hydephp/204-go-over-router-namespaces-be…
Browse files Browse the repository at this point in the history
…fore-release

Update Router namespaces
  • Loading branch information
caendesilva authored Jul 9, 2022
2 parents 3c3173e + bbe76cc commit 6437065
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 75 deletions.
33 changes: 23 additions & 10 deletions packages/framework/resources/views/layouts/navigation.blade.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
@php
$navigation = \Hyde\Framework\Modules\Navigation\NavigationMenu::create($page->getRoute());
$navigation = \Hyde\Framework\Models\NavigationMenu::create($page->getRoute());
@endphp

<nav aria-label="Main navigation" id="main-navigation" class="flex flex-wrap items-center justify-between p-4 shadow-lg sm:shadow-xl md:shadow-none dark:bg-gray-800">
<nav aria-label="Main navigation" id="main-navigation"
class="flex flex-wrap items-center justify-between p-4 shadow-lg sm:shadow-xl md:shadow-none dark:bg-gray-800">
<div class="flex flex-grow items-center flex-shrink-0 text-gray-700 dark:text-gray-200">
@include('hyde::components.navigation.navigation-brand')

<div class="ml-auto">
@include('hyde::components.navigation.theme-toggle-button')
@include('hyde::components.navigation.theme-toggle-button')
</div>
</div>

<div class="block md:hidden">
<button id="navigation-toggle-button" class="flex items-center px-3 py-1 hover:text-gray-700 dark:text-gray-200" aria-label="Toggle navigation menu">
<svg title="Open Navigation Menu" class="dark:fill-gray-200" style="display: block;" id="open-main-navigation-menu-icon" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><title>Open Menu</title><path d="M0 0h24v24H0z" fill="none"/><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>
<svg title="Close Navigation Menu" class="dark:fill-gray-200" style="display: none;" id="close-main-navigation-menu-icon" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><title>Close Menu</title> <path d="M0 0h24v24H0z" fill="none"></path> <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path> </svg>
<button id="navigation-toggle-button" class="flex items-center px-3 py-1 hover:text-gray-700 dark:text-gray-200"
aria-label="Toggle navigation menu">
<svg title="Open Navigation Menu" class="dark:fill-gray-200" style="display: block;"
id="open-main-navigation-menu-icon" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24"
width="24"><title>Open Menu</title>
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
</svg>
<svg title="Close Navigation Menu" class="dark:fill-gray-200" style="display: none;"
id="close-main-navigation-menu-icon" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24"
width="24"><title>Close Menu</title>
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path>
</svg>
</button>
</div>

<div id="main-navigation-links" class="w-full hidden md:flex flex-grow md:flex-grow-0 md:items-center md:w-auto px-6 -mx-4 border-t mt-3 pt-3 md:border-none md:mt-0 md:py-0 border-gray-200 dark:border-gray-700">
<div id="main-navigation-links"
class="w-full hidden md:flex flex-grow md:flex-grow-0 md:items-center md:w-auto px-6 -mx-4 border-t mt-3 pt-3 md:border-none md:mt-0 md:py-0 border-gray-200 dark:border-gray-700">
<ul aria-label="Navigation links" class="md:flex-grow md:flex justify-end">
@foreach ($navigation->items as $item)
<li class="md:mx-2">
@include('hyde::components.navigation.navigation-link')
</li>
<li class="md:mx-2">
@include('hyde::components.navigation.navigation-link')
</li>
@endforeach
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/src/Concerns/CanBeInNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function navigationMenuTitle(): string
* If an item returns a route collection,
* it will automatically be made into a dropdown.
*
* @return \Illuminate\Support\Collection<\Hyde\Framework\Modules\Routing\Route>
* @return \Illuminate\Support\Collection<\Hyde\Framework\Models\Route>
*/
// public function navigationMenuChildren(): Collection;
}
2 changes: 1 addition & 1 deletion packages/framework/src/Contracts/AbstractPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Hyde\Framework\Concerns\CanBeInNavigation;
use Hyde\Framework\Concerns\HasPageMetadata;
use Hyde\Framework\Modules\Routing\Route;
use Hyde\Framework\Models\Route;
use Hyde\Framework\Services\CollectionService;
use Illuminate\Support\Collection;

Expand Down
3 changes: 1 addition & 2 deletions packages/framework/src/Contracts/PageContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Hyde\Framework\Contracts;

use Hyde\Framework\Modules\Routing\RouteContract;
use Illuminate\Support\Collection;

interface PageContract
Expand Down Expand Up @@ -115,7 +114,7 @@ public function getCurrentPagePath(): string;
/**
* Get the route for the page.
*
* @return \Hyde\Framework\Modules\Routing\RouteContract
* @return \Hyde\Framework\Contracts\RouteContract
*/
public function getRoute(): RouteContract;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<?php

namespace Hyde\Framework\Modules\Routing;

use Hyde\Framework\Contracts\PageContract;
namespace Hyde\Framework\Contracts;

/**
* This contract defines the methods that a Route object must implement.
* These methods are each applied to the single route instance.
*
* In Hyde, the route models also serve as a facade for all routes, see the dedicated interface:
*
* @see \Hyde\Framework\Modules\Routing\RouteFacadeContract for the static facade methods.
* @see \Hyde\Framework\Contracts\RouteFacadeContract for the static facade methods.
*/
interface RouteContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

namespace Hyde\Framework\Modules\Routing;
namespace Hyde\Framework\Contracts;

use Hyde\Framework\Contracts\PageContract;
use Illuminate\Support\Collection;

/**
* This contract defines the static facade methods for the Route class.
*
* @see \Hyde\Framework\Modules\Routing\RouteContract for the interface that each route model must implement.
* @see \Hyde\Framework\Contracts\RouteContract for the interface that each route model must implement.
*/
interface RouteFacadeContract
{
Expand All @@ -18,46 +17,46 @@ interface RouteFacadeContract
* Alias for static::getFromKey().
*
* @param string $routeKey Example: posts/foo.md
* @return \Hyde\Framework\Modules\Routing\RouteContract
* @return \Hyde\Framework\Contracts\RouteContract
*
* @throws \Hyde\Framework\Modules\Routing\RouteNotFoundException
* @throws \Hyde\Framework\Exceptions\RouteNotFoundException
*/
public static function get(string $routeKey): RouteContract;

/**
* Get a route from the Router index for the specified route key.
*
* @param string $routeKey Example: posts/foo.md
* @return \Hyde\Framework\Modules\Routing\RouteContract
* @return \Hyde\Framework\Contracts\RouteContract
*
* @throws \Hyde\Framework\Modules\Routing\RouteNotFoundException
* @throws \Hyde\Framework\Exceptions\RouteNotFoundException
*/
public static function getFromKey(string $routeKey): RouteContract;

/**
* Get a route from the Router index for the specified source file path.
*
* @param string $sourceFilePath Example: _posts/foo.md
* @return \Hyde\Framework\Modules\Routing\RouteContract
* @return \Hyde\Framework\Contracts\RouteContract
*
* @throws \Hyde\Framework\Modules\Routing\RouteNotFoundException
* @throws \Hyde\Framework\Exceptions\RouteNotFoundException
*/
public static function getFromSource(string $sourceFilePath): RouteContract;

/**
* Get a route from the Router index for the supplied page model.
*
* @param \Hyde\Framework\Contracts\PageContract $page
* @return \Hyde\Framework\Modules\Routing\RouteContract
* @return \Hyde\Framework\Contracts\RouteContract
*
* @throws \Hyde\Framework\Modules\Routing\RouteNotFoundException
* @throws \Hyde\Framework\Exceptions\RouteNotFoundException
*/
public static function getFromModel(PageContract $page): RouteContract;

/**
* Get all routes from the Router index.
*
* @return \Illuminate\Support\Collection<\Hyde\Framework\Modules\Routing\RouteContract>
* @return \Illuminate\Support\Collection<\Hyde\Framework\Contracts\RouteContract>
*/
public static function all(): Collection;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Hyde\Framework\Modules\Routing;
namespace Hyde\Framework\Contracts;

use Illuminate\Support\Collection;

Expand All @@ -21,15 +21,15 @@ public static function getInstance(): RouterContract;
/**
* Get the routes discovered by the router.
*
* @return \Illuminate\Support\Collection<\Hyde\Framework\Modules\Routing\RouteContract>
* @return \Illuminate\Support\Collection<\Hyde\Framework\Contracts\RouteContract>
*/
public function getRoutes(): Collection;

/**
* Get all discovered routes for the given page class.
*
* @param class-string<\Hyde\Framework\Contracts\PageContract> $pageClass
* @return \Illuminate\Support\Collection<\Hyde\Framework\Modules\Routing\RouteContract>
* @return \Illuminate\Support\Collection<\Hyde\Framework\Contracts\RouteContract>
*/
public function getRoutesForModel(string $pageClass): Collection;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Hyde\Framework\Modules\Routing;
namespace Hyde\Framework\Exceptions;

class RouteNotFoundException extends \Exception
{
Expand Down
6 changes: 3 additions & 3 deletions packages/framework/src/Facades/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace Hyde\Framework\Facades;

use Hyde\Framework\Contracts\PageContract;
use Hyde\Framework\Modules\Routing\Route as RouteModel;
use Hyde\Framework\Modules\Routing\RouteFacadeContract;
use Hyde\Framework\Contracts\RouteFacadeContract;
use Hyde\Framework\Models\Route as RouteModel;
use Illuminate\Support\Collection;

/**
* @see \Hyde\Framework\Modules\Routing\Route
* @see \Hyde\Framework\Models\Route
* @see \Hyde\Framework\Testing\Feature\RouteFacadeTest
*/
class Route implements RouteFacadeContract
Expand Down
5 changes: 2 additions & 3 deletions packages/framework/src/Models/NavItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
namespace Hyde\Framework\Models;

use Hyde\Framework\Contracts\PageContract;
use Hyde\Framework\Facades\Route;
use Hyde\Framework\Modules\Routing\RouteContract;
use Hyde\Framework\Contracts\RouteContract;

/**
* Abstraction for a navigation menu item.
Expand All @@ -26,7 +25,7 @@ class NavItem
/**
* Create a new navigation menu item.
*
* @param \Hyde\Framework\Modules\Routing\RouteContract|null $route
* @param \Hyde\Framework\Contracts\RouteContract|null $route
* @param string $title
* @param int $priority
* @param bool $hidden
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php

namespace Hyde\Framework\Modules\Navigation;
namespace Hyde\Framework\Models;

use Hyde\Framework\Models\NavItem;
use Hyde\Framework\Modules\Routing\Route;
use Hyde\Framework\Modules\Routing\RouteContract;
use Hyde\Framework\Modules\Routing\Router;
use Hyde\Framework\Contracts\RouteContract;
use Hyde\Framework\Router;
use Illuminate\Support\Collection;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?php

namespace Hyde\Framework\Modules\Routing;
namespace Hyde\Framework\Models;

use Hyde\Framework\Contracts\PageContract;
use Hyde\Framework\Contracts\RouteContract;
use Hyde\Framework\Contracts\RouteFacadeContract;
use Hyde\Framework\Exceptions\RouteNotFoundException;
use Hyde\Framework\Hyde;
use Hyde\Framework\Router;
use Illuminate\Support\Collection;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php

namespace Hyde\Framework\Modules\Routing;
namespace Hyde\Framework;

use Hyde\Framework\Contracts\PageContract;
use Hyde\Framework\Contracts\RouteContract;
use Hyde\Framework\Contracts\RouterContract;
use Hyde\Framework\Helpers\Features;
use Hyde\Framework\Models\Pages\BladePage;
use Hyde\Framework\Models\Pages\DocumentationPage;
use Hyde\Framework\Models\Pages\MarkdownPage;
use Hyde\Framework\Models\Pages\MarkdownPost;
use Hyde\Framework\Models\Route;
use Illuminate\Support\Collection;

/**
Expand Down Expand Up @@ -42,7 +45,7 @@ class Router implements RouterContract
/**
* The routes discovered by the router.
*
* @var \Illuminate\Support\Collection<\Hyde\Framework\Modules\Routing\RouteContract>
* @var \Illuminate\Support\Collection<\Hyde\Framework\Contracts\RouteContract>
*/
protected Collection $routes;

Expand Down
4 changes: 2 additions & 2 deletions packages/framework/src/Services/BuildService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Hyde\Framework\Services;

use Hyde\Framework\Concerns\InteractsWithDirectories;
use Hyde\Framework\Contracts\RouteContract as Route;
use Hyde\Framework\Hyde;
use Hyde\Framework\Modules\Routing\RouteContract as Route;
use Hyde\Framework\Modules\Routing\Router;
use Hyde\Framework\Router;
use Hyde\Framework\StaticPageBuilder;
use Illuminate\Console\Concerns\InteractsWithIO;
use Illuminate\Console\OutputStyle;
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/src/Services/RebuildService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Hyde\Framework\Services;

use Hyde\Framework\Modules\Routing\Route;
use Hyde\Framework\Models\Route;
use Hyde\Framework\StaticPageBuilder;

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Feature/AbstractPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Hyde\Framework\Models\Pages\MarkdownPost;
use Hyde\Framework\Models\Parsers\MarkdownPageParser;
use Hyde\Framework\Models\Parsers\MarkdownPostParser;
use Hyde\Framework\Modules\Routing\Route;
use Hyde\Framework\Models\Route;
use Hyde\Testing\TestCase;

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/framework/tests/Feature/NavigationMenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Hyde\Framework\Testing\Feature;

use Hyde\Framework\Hyde;
use Hyde\Framework\Models\NavigationMenu;
use Hyde\Framework\Models\NavItem;
use Hyde\Framework\Modules\Navigation\NavigationMenu;
use Hyde\Framework\Modules\Routing\Route;
use Hyde\Framework\Models\Route;
use Hyde\Testing\TestCase;
use Illuminate\Support\Collection;

/**
* @covers \Hyde\Framework\Modules\Navigation\NavigationMenu
* @covers \Hyde\Framework\Models\NavigationMenu
*/
class NavigationMenuTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Feature/RouteFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Hyde\Framework\Facades\Route;
use Hyde\Framework\Models\Pages\BladePage;
use Hyde\Framework\Modules\Routing\Route as BaseRoute;
use Hyde\Framework\Models\Route as BaseRoute;
use Hyde\Testing\TestCase;

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/framework/tests/Feature/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

namespace Hyde\Framework\Testing\Feature;

use Hyde\Framework\Contracts\RouteContract;
use Hyde\Framework\Exceptions\RouteNotFoundException;
use Hyde\Framework\Hyde;
use Hyde\Framework\Models\Pages\BladePage;
use Hyde\Framework\Models\Pages\DocumentationPage;
use Hyde\Framework\Models\Pages\MarkdownPage;
use Hyde\Framework\Models\Pages\MarkdownPost;
use Hyde\Framework\Modules\Routing\Route;
use Hyde\Framework\Modules\Routing\RouteContract;
use Hyde\Framework\Modules\Routing\RouteNotFoundException;
use Hyde\Framework\Modules\Routing\Router;
use Hyde\Framework\Models\Route;
use Hyde\Framework\Router;
use Hyde\Testing\TestCase;

/**
* @covers \Hyde\Framework\Modules\Routing\Route
* @covers \Hyde\Framework\Models\Route
*/
class RouteTest extends TestCase
{
Expand Down
Loading

0 comments on commit 6437065

Please sign in to comment.