Skip to content

Commit

Permalink
bugfix : route utility bug & added exception
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownRori committed Feb 18, 2022
1 parent 78536bb commit 68172a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion core/Support/http/route/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Core\KernelException;
use Core\Support\Http\Middleware;
use Exception;

class Route implements IRoute
{
Expand Down Expand Up @@ -179,7 +180,11 @@ public function name($name)
*/
public static function GetRoute($name, $data = [])
{
$uri = self::$nameRoute[$name];
if(array_key_exists($name, self::$nameRoute)){
$uri = self::$nameRoute[$name];
}else {
throw new Exception("Named Route {$name} is not registered in the route! did you forgot to register it?");
}

$value = array_values($data);
$key = array_keys($data);
Expand Down
4 changes: 2 additions & 2 deletions core/utils/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @param array $data
* @return void
*/
function redirect($name, $data = null)
function redirect($name, $data = [])
{
return Route::Redirect($name, $data);
}
Expand All @@ -19,7 +19,7 @@ function redirect($name, $data = null)
* @param array $data
* @return string
*/
function route($name, $data = null)
function route($name, $data = [])
{
return Route::GetRoute($name, $data);
}

0 comments on commit 68172a2

Please sign in to comment.