-
Notifications
You must be signed in to change notification settings - Fork 66
drop DynamicRouter::match #116
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,12 +25,14 @@ | |
interface ChainRouterInterface extends RouterInterface, RequestMatcherInterface | ||
{ | ||
/** | ||
* Add a Router to the index | ||
* Add a Router to the index. | ||
* | ||
* @param RouterInterface $router The router instance | ||
* @param integer $priority The priority | ||
* The router must implement either RouterInterface or RequestMatcherInterface and UrlGeneratorInterface. | ||
* | ||
* @param RouterInterface|RequestMatcherInterface $router The router instance | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this phpdoc does not match the validation in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the full thruth is: RouterInterface|RequestMatcherInterface&UrlGeneratorInterface (or however the syntax for this would be). RouterInterface is the common interface of UrlMatcherInterface and UrlGeneratorInterface. for RequestMatcher there is no such common interface. |
||
* @param integer $priority The priority | ||
*/ | ||
public function add(RouterInterface $router, $priority = 0); | ||
public function add($router, $priority = 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if anybody is using this interface. but it was too restrictive. can we do this? otherwise we would need to keep should this go into changelog as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
|
||
/** | ||
* Sorts the routers and flattens them. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ | |
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Routing\RequestContext; | ||
use Symfony\Component\Routing\RouteCollection; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use Symfony\Component\Routing\Matcher\RequestMatcherInterface; | ||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface; | ||
|
@@ -34,7 +33,7 @@ | |
* @author Larry Garfield | ||
* @author David Buchmann | ||
*/ | ||
class DynamicRouter implements RouterInterface, RequestMatcherInterface, ChainedRouterInterface | ||
class DynamicRouter implements UrlGeneratorInterface, RequestMatcherInterface, ChainedRouterInterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change has actually a higher chance of biting people, if they relied on DynamicRouter implementing RouterInterface. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ChainedRouterInterface extends the RouterInterface. this is a problem as we want to drop the UrlMatcherInterface. we could change ChainedRouterInterface to use RequestMatcherInterface and UrlGeneratorInterface instead of RouterInterface. |
||
{ | ||
/** | ||
* @var RequestMatcherInterface|UrlMatcherInterface | ||
|
@@ -183,45 +182,6 @@ public function supports($name) | |
return is_string($name); | ||
} | ||
|
||
/** | ||
* Tries to match a URL path with a set of routes. | ||
* | ||
* If the matcher can not find information, it must throw one of the | ||
* exceptions documented below. | ||
* | ||
* @param string $pathinfo The path info to be parsed (raw format, i.e. not | ||
* urldecoded) | ||
* | ||
* @return array An array of parameters | ||
* | ||
* @throws ResourceNotFoundException If the resource could not be found | ||
* @throws MethodNotAllowedException If the resource was found but the | ||
* request method is not allowed | ||
* | ||
* @api | ||
*/ | ||
public function match($pathinfo) | ||
{ | ||
$request = Request::create($pathinfo); | ||
if ($this->eventDispatcher) { | ||
$event = new RouterMatchEvent(); | ||
$this->eventDispatcher->dispatch(Events::PRE_DYNAMIC_MATCH, $event); | ||
} | ||
|
||
if (! empty($this->uriFilterRegexp) && ! preg_match($this->uriFilterRegexp, $pathinfo)) { | ||
throw new ResourceNotFoundException("$pathinfo does not match the '{$this->uriFilterRegexp}' pattern"); | ||
} | ||
|
||
$matcher = $this->getMatcher(); | ||
if (! $matcher instanceof UrlMatcherInterface) { | ||
throw new \InvalidArgumentException('Wrong matcher type, you need to call matchRequest'); | ||
} | ||
|
||
$defaults = $matcher->match($pathinfo); | ||
|
||
return $this->applyRouteEnhancers($defaults, $request); | ||
} | ||
|
||
/** | ||
* Tries to match a request with a set of routes and returns the array of | ||
* information for that route. | ||
|
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.
puh .. that is a very tricky if statement ..
seems like there should be some additional parenthesis in there.
also in the phpdoc for
ChainRouterInterface
you specifyRouterInterface|RequestMatcherInterface
which would be quite a lot simpler to express than the above ..also shouldn't we say what a valid router is?
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.
you mean paranthesis around the inner
&&
? i can do that if you think it helps.where would you say what a valid router is? in the interface phpdoc? or in the exception message?