Skip to content

Commit 38311fa

Browse files
authored
Merge pull request #100 from sunrise-php/release/v2.16.0
v2.16.0
2 parents 13f5d0a + 88e7969 commit 38311fa

34 files changed

+53
-30
lines changed

CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
## v2.13.0
1+
# v2.16.0
22

3-
* Supports for events using the `symfony/event-dispatcher`.
3+
* New method: `Router::hasRoute(string):bool`.
4+
5+
## v2.15.0
6+
7+
* New middleware: `Sunrise\Http\Router\Middleware\JsonPayloadDecodingMiddleware`.
48

59
## v2.14.0
610

@@ -9,6 +13,6 @@
913
* New method: `Router::getRoutesByHostname(string):array`;
1014
* New method: `RouterBuilder::setEventDispatcher(?EventDispatcherInterface):void`.
1115

12-
## v2.15.0
16+
## v2.13.0
1317

14-
* New middleware: `Sunrise\Http\Router\Middleware\JsonPayloadDecodingMiddleware`.
18+
* Supports for events using the `symfony/event-dispatcher`.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Sunrise // PHP
3+
Copyright (c) 2018 Anatoly Nekhay
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,16 @@ use Sunrise\Http\Router\Middleware\JsonPayloadDecodingMiddleware;
480480
$router->addMiddleware(new JsonPayloadDecodingMiddleware());
481481
```
482482

483+
### Get a route by name
484+
485+
```php
486+
// checks if a route is exists
487+
$router->hasRoute('foo');
488+
489+
// gets a route by name
490+
$router->getRoute('foo');
491+
```
492+
483493
### Get a current route
484494

485495
#### Through Router
@@ -642,9 +652,10 @@ $route->getHolder(); // return Reflector (class, method or function)
642652

643653
```php
644654
$router = (new RouterBuilder)
645-
->setContainer(null) // null or PSR-11 container instance...
646-
->setCache(null) // null or PSR-16 cache instance... (only for descriptor loader)
647-
->setCacheKey(null) // null or string... (only for descriptor loader)
655+
->setEventDispatcher(...) // null or use to symfony/event-dispatcher...
656+
->setContainer(...) // null or PSR-11 container instance...
657+
->setCache(...) // null or PSR-16 cache instance... (only for descriptor loader)
658+
->setCacheKey(...) // null or string... (only for descriptor loader)
648659
->useConfigLoader([]) // array with files or directory with files...
649660
->useDescriptorLoader([]) // array with classes or directory with classes...
650661
->setHosts([]) //

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
22
"name": "sunrise/http-router",
33
"homepage": "https://github.com/sunrise-php/http-router",
4-
"description": "Sunrise // HTTP router for PHP 7.1+ based on PSR-7 and PSR-15 with support for annotations/attributes and OpenAPI (Swagger) Specification",
4+
"description": "HTTP router for PHP 7.1+ based on PSR-7 and PSR-15 with support for annotations/attributes and OpenAPI (Swagger) Specification",
55
"license": "MIT",
66
"keywords": [
77
"fenric",
88
"sunrise",
99
"http",
1010
"router",
11-
"annotations",
11+
"request-handler",
1212
"middlewares",
13+
"annotations",
14+
"attributes",
1315
"openapi",
16+
"swagger",
1417
"psr-7",
1518
"psr-15",
1619
"php7",
17-
"php8",
18-
"attributes",
19-
"php-attributes",
20-
"swagger"
20+
"php8"
2121
],
2222
"authors": [
2323
{
@@ -28,12 +28,12 @@
2828
],
2929
"require": {
3030
"php": "^7.1|^8.0",
31+
"fig/http-message-util": "^1.1",
3132
"psr/container": "^1.0",
3233
"psr/http-message": "^1.0",
3334
"psr/http-server-handler": "^1.0",
3435
"psr/http-server-middleware": "^1.0",
35-
"psr/simple-cache": "^1.0",
36-
"fig/http-message-util": "^1.1"
36+
"psr/simple-cache": "^1.0"
3737
},
3838
"require-dev": {
3939
"phpunit/phpunit": "7.5.20|9.5.0",
@@ -58,7 +58,7 @@
5858
},
5959
"autoload-dev": {
6060
"psr-4": {
61-
"Sunrise\\Http\\Router\\Tests\\Fixtures\\": "tests/fixtures/"
61+
"Sunrise\\Http\\Router\\Tests\\": "tests/"
6262
}
6363
},
6464
"scripts": {

src/Router.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,16 @@ public function getAllowedMethods() : array
365365
return array_keys($methods);
366366
}
367367

368+
/**
369+
* Checks if a route exists by the given name
370+
*
371+
* @return bool
372+
*/
373+
public function hasRoute(string $name) : bool
374+
{
375+
return isset($this->routes[$name]);
376+
}
377+
368378
/**
369379
* Gets a route for the given name
370380
*
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)