-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
199 additions
and
54 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
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
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,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Router\Attribute; | ||
|
||
use Attribute; | ||
use Stringable; | ||
use Yiisoft\Router\Route as RouteObject; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] | ||
final class Route implements RouteAttributeInterface | ||
{ | ||
private RouteObject $route; | ||
|
||
/** | ||
* @param array<string,scalar|Stringable|null> $defaults Parameter default values indexed by parameter names. | ||
* @param bool $override Marks route as override. When added it will replace existing route with the same name. | ||
* @param array $disabledMiddlewares Excludes middleware from being invoked when action is handled. | ||
* It is useful to avoid invoking one of the parent group middleware for | ||
* a certain route. | ||
*/ | ||
public function __construct( | ||
array $methods, | ||
string $pattern, | ||
?string $name = null, | ||
array $middlewares = [], | ||
array $defaults = [], | ||
array $hosts = [], | ||
bool $override = false, | ||
array $disabledMiddlewares = [] | ||
) { | ||
$this->route = new RouteObject( | ||
methods: $methods, | ||
pattern: $pattern, | ||
name: $name, | ||
middlewares: $middlewares, | ||
defaults: $defaults, | ||
hosts: $hosts, | ||
override: $override, | ||
disabledMiddlewares: $disabledMiddlewares | ||
); | ||
} | ||
|
||
public function getRoute(): RouteObject | ||
{ | ||
return $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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Router\Attribute; | ||
|
||
use Yiisoft\Router\Route; | ||
|
||
interface RouteAttributeInterface | ||
{ | ||
public function getRoute(): 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
Oops, something went wrong.