Create routes by array, and return a Router object
public static parseConfig ( array $config ) : |
||
$config | array | provide by Config::loadFromFile() |
return |
/** * Router runner * * @throws NotFoundException * @return bool|\PHPRouter\Route */ public function run() { $routes = Config::loadFromFile($this->routePath); $router = Route::parseConfig($routes); $exec = $router->matchCurrentRequest(); if ($exec) { return $exec; } throw new NotFoundException('Route does not found', NotFoundException::CODE); }
public function testParseConfig() { $config = Config::loadFromFile(__DIR__ . '/../../Fixtures/router.yaml'); $router = Router::parseConfig($config); self::assertAttributeEquals($config['base_path'], 'basePath', $router); }