Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezasalehizadeh committed Nov 4, 2023
1 parent 484badd commit c487fd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 47 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
],
"require": {
"php": "^8.0",
"symfony/routing": "^6.2",
"alirezasalehizadeh/quick-migration": "^1.7.5",
"alirezasalehizadeh/routail": "^1.0",
"alirezasalehizadeh/quick-migration": "^1.8.0",
"illuminate/container": "^10.24"
},
"require-dev": {
"phpunit/phpunit": "^9.6"
}
}
}
48 changes: 4 additions & 44 deletions src/Route/Router.php
Original file line number Diff line number Diff line change
@@ -1,49 +1,9 @@
<?php

namespace Makaroni\Core\Route;

use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use AlirezaSalehizadeh\Routail\Router as Routail;

class Router
class Router extends Routail
{

private static $router;

private static $routes;

private function __construct()
{
static::$routes = new RouteCollection();

}

public static function getInstance(): object {
if(self::$router == null) {
$router=self::$router = new Router();
}
return $router;
}


public function add(string $path, array $defaults, string $name): void
{
$route = new Route($path, ['controller' => $defaults[0], 'method' => $defaults[1]]);
static::$routes->add($name, $route);

}

public function load(string $routeFilePath): object
{
require_once $routeFilePath;
return $this;
}

public function find(string $pathinfo): array
{
$context = new RequestContext();
$matcher = new UrlMatcher(static::$routes, $context);
return $matcher->match($pathinfo);
}
}
}

0 comments on commit c487fd6

Please sign in to comment.