-
Notifications
You must be signed in to change notification settings - Fork 7
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
Standard dispatch result #91
Conversation
$method = $routerInfo[1][1]; | ||
$function = (new ReflectionClass($controller))->getShortName(); | ||
if (!($routeInfo instanceof RouteInfoInterface)) { | ||
throw new \RuntimeException('Dispatch does not return RouteInfo object'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move RuntimeException to use statement
9652784
to
d1cbd1c
Compare
RouteInfo is a new class that increase interoperability between router libraries, this is the result of dispatch and it contains all info necessary to complete the RUN
d1cbd1c
to
2f8d26f
Compare
Works! :) I have only a little problem with PHP 7.. |
I've given a try to patch php7 issue in #92 , let see |
This fix doesn't sound good but works.. |
seems weird as previously, |
btw, need additional tests |
Feature/route info call user func approach
Thanks at all! We have a RouteInfo! 👍 |
private $callable; | ||
private $params; | ||
|
||
public static function matched($name, callable $callable, $params = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this method?
public function __construct($name, callable $callable, $params = []) {
// ...
}
Is not better? In that way you can simplify the RouteInfoInterface and let to the user the RouteInfo construction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$matched = new RouteInfo("name", function() {}, []);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.. maybe it is more easy to use 💣 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion also because a match
method is more related to the Router
and not the matched
route, do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes :).. are you interested to write a PR? Otherwise I write a PR this evening :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course i will try with a new PR
|
||
interface RouteInfoInterface | ||
{ | ||
public static function matched($name, callable $callable, $params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no reason to have this method in the RouteInfoInterface
imho.
This PR implements a new class
RouteInfo
to return a standard result ofdisptach
method.This object describe current route resolved by dispatcher and helps us to implement new router libraries.
Reference #16