-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRoute.php
60 lines (52 loc) · 1.47 KB
/
Route.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace Hyde\Facades;
use Hyde\Foundation\RouteCollection;
/**
* Provides an easy way to access the Hyde pseudo-router.
*/
class Route
{
/**
* Get a route from the route index for the specified route key.
*
* @param string $routeKey Example: posts/foo.md
*/
public static function get(string $routeKey): ?\Hyde\Support\Models\Route
{
return \Hyde\Support\Models\Route::get($routeKey);
}
/**
* Get a route from the route index for the specified route key or throw an exception.
*
*
* @throws \Hyde\Framework\Exceptions\RouteNotFoundException
*/
public static function getOrFail(string $routeKey): \Hyde\Support\Models\Route
{
return \Hyde\Support\Models\Route::getOrFail($routeKey);
}
/**
* Get all routes from the route index.
*
* @return \Hyde\Foundation\RouteCollection<\Hyde\Support\Models\Route>
*/
public static function all(): RouteCollection
{
return \Hyde\Support\Models\Route::all();
}
/**
* Get the current route for the page being rendered.
*/
public static function current(): ?\Hyde\Support\Models\Route
{
return \Hyde\Support\Models\Route::current();
}
/**
* Determine if the supplied route key exists in the route index.
*/
public static function exists(string $routeKey): bool
{
return \Hyde\Support\Models\Route::exists($routeKey);
}
}