-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: route name, route middleware, route head
- suport named route - suport route view - support route with HEAD method
- Loading branch information
1 parent
d8e82b9
commit 043373f
Showing
7 changed files
with
196 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace System\Router; | ||
|
||
abstract class AbstractMiddleware | ||
{ | ||
public function handle() | ||
{ | ||
// ovveridedable | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace System\Router; | ||
|
||
abstract class Controller | ||
{ | ||
public function __invoke($invoke) | ||
{ | ||
call_user_func([$this, $invoke]); | ||
} | ||
|
||
public static function renderView($view_name, $portal) | ||
{ | ||
// overwrite | ||
} | ||
|
||
/** | ||
* @var static This classs | ||
*/ | ||
private self $_static; | ||
|
||
/** | ||
* Instance of controller. | ||
* Shorthadn to crete new class | ||
*/ | ||
public static function static() | ||
{ | ||
return self::$_static ?? new static; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace System\Router; | ||
|
||
class RouteNamed | ||
{ | ||
private $route; | ||
|
||
public function __construct(array $route, ?string $default_name = 'global') | ||
{ | ||
$route['name'] = $default_name ?? 'global'; | ||
$this->route = $route; | ||
} | ||
|
||
public function name(string $name) | ||
{ | ||
$this->route['name'] =$name; | ||
} | ||
|
||
public function __destruct() | ||
{ | ||
Router::addRoutes($this->route); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
use System\Router\AbstractMiddleware; | ||
|
||
class TestMiddleware extends AbstractMiddleware | ||
{ | ||
public function handle() | ||
{ | ||
$_SERVER['middleware'] = 'oke'; | ||
} | ||
} |