-
-
Notifications
You must be signed in to change notification settings - Fork 137
fix(router): use route registry to generate uris #1724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
30e589c
fix(router): use route registry to generate uris
innocenzi 6d662fb
style: remove new rector rule
innocenzi 330b60e
feat(router): throw exception when generating an uri to a controller …
innocenzi 9085833
Merge branch 'main' into fix/uri-generation
brendt e816109
Remove multi route check
brendt 7e5422b
Multi prefixs support
brendt ce8fa86
QA
brendt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/router/src/Exceptions/ControllerActionDoesNotExist.php
This file contains hidden or 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,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Tempest\Router\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| final class ControllerActionDoesNotExist extends Exception implements RouterException | ||
| { | ||
| public static function controllerNotFound(string $controller): self | ||
| { | ||
| return new self("The controller class `{$controller}` does not exist."); | ||
| } | ||
|
|
||
| public static function actionNotFound(string $controller, string $method): self | ||
| { | ||
| return new self("The method `{$method}()` does not exist in controller class `{$controller}`."); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
packages/router/src/Exceptions/ControllerMethodHadNoRoute.php
This file contains hidden or 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,15 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Tempest\Router\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| final class ControllerMethodHadNoRoute extends Exception implements RouterException | ||
| { | ||
| public function __construct(string $controllerClass, string $controllerMethod) | ||
| { | ||
| parent::__construct("No route found for `{$controllerClass}::{$controllerMethod}()`. Did you forget to add a `Route` attribute?"); | ||
| } | ||
| } |
15 changes: 0 additions & 15 deletions
15
packages/router/src/Exceptions/ControllerMethodHadNoRouteAttribute.php
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
packages/router/src/Exceptions/ControllerMethodHasMultipleRoutes.php
This file contains hidden or 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,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Tempest\Router\Exceptions; | ||
|
|
||
| use Exception; | ||
| use Tempest\Support\Arr; | ||
|
|
||
| final class ControllerMethodHasMultipleRoutes extends Exception implements RouterException | ||
| { | ||
| /** @param string[] $routes */ | ||
| public function __construct(string $controllerClass, string $controllerMethod, array $routes) | ||
| { | ||
| parent::__construct(vsprintf( | ||
| format: "Controller method `%s::%s()` has multiple different routes: \"%s\". Please use the route path directly.", | ||
| values: [ | ||
| $controllerClass, | ||
| $controllerMethod, | ||
| Arr\join($routes), | ||
| ], | ||
| )); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.