Skip to content
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

DynamicRouter can't be used exactly like ChainedRouter #151

Closed
dawehner opened this issue Sep 29, 2015 · 13 comments
Closed

DynamicRouter can't be used exactly like ChainedRouter #151

dawehner opened this issue Sep 29, 2015 · 13 comments

Comments

@dawehner
Copy link
Contributor

Given the architecture I'd expect that you could switch off ChainedRouter without having any problem,
but it turns out, you require it for ->match() calls

@dbu
Copy link
Member

dbu commented Sep 29, 2015

applications should only use what the RouterInterface or the UrlMatcherInterface / RequestMatcherInterface provides.

what exactly is the problem? either its a bug of DynamicRouter or ChainedRouter is cleaning up something wobbly that you are doing, so more hiding a problem you already have.

@dawehner
Copy link
Contributor Author

So if you use DynamicRouter directly but your matcher is NestedMatcher it just doesn't work, its a bit sad that DynamicRouter does not also provide the wrapping like ChainedRouter does

@dbu
Copy link
Member

dbu commented Sep 29, 2015 via email

@dawehner
Copy link
Contributor Author

HI.

Well, for normal routing we use ::matchRequest() which works perfect. For some internal validation of user entered path we used to use ::match() but I think its fine to just replace that single call

@dawehner
Copy link
Contributor Author

See https://www.drupal.org/files/issues/2576809-11.patch for the adaptions which needed to be made

@dbu
Copy link
Member

dbu commented Sep 30, 2015

if i read that diff correctly, the only change related to the different behaviour is this:

-      return $router->match($path);
+      $subrequest = Request::create($path);
+      return $router->matchRequest($subrequest);

this seems not too heavy to me.

the rest is having to do with assumptions and the different interfaces that may or may not be implemented when you want to be generic.

+    if ($this->chainRouter instanceof RequestContextAwareInterface) {
+      $this->chainRouter->getContext();
+    }
+    throw new \RuntimeException();

this is missing a return i think.

i don't know the context but i wonder why you do not require a RouterInterface to be injected if you want to decorate a router.

+    if ($this->chainRouter instanceof RouterInterface) {
+      return $this->chainRouter->generate($name, $parameters, $referenceType);
+    }
+    throw new \RuntimeException();

@dbu
Copy link
Member

dbu commented Sep 30, 2015

btw, also not #147 and #152 where people want to change how the ChainRouter match vs matchRequest behaves. and even more related things, there is the idea to only have a matchRequest method in symfony 3: symfony/symfony#9781

@dbu
Copy link
Member

dbu commented Sep 30, 2015

@dawehner btw, #147 is about Request::create() doing unexpected things on //foo (since some symfony bugfix, this is no longer considered a path but a domain without protocol).

@lsmith77
Copy link
Member

lsmith77 commented Oct 8, 2015

instead of throwing an exception if we do not have an UrlMatcherInterface, we duplicate the same logic from the ChainRouter::doMatch() method .. does that work for you?

@dawehner
Copy link
Contributor Author

dawehner commented Oct 8, 2015

Yeah that would be a little bit more convient. Not sure what you think: So
you think the DynamicRouter should be usable as it is?

On Thu, Oct 8, 2015 at 11:45 AM, Lukas Kahwe Smith <notifications@github.com

wrote:

instead of throwing an exception if we do not have an UrlMatcherInterface,
we duplicate the same logic from the ChainRouter::doMatch() method ..
does that work for you?


Reply to this email directly or view it on GitHub
#151 (comment)
.

@lsmith77
Copy link
Member

we might be able to solve this via symfony/symfony#16346
but this might mean we decide to bump this lib to 2.0 .. lets see

/cc @Tobion @lolautruche

@dbu
Copy link
Member

dbu commented Nov 4, 2015

@dawehner ok for you if you simply do the Request::create for now and we close this issue? the next major version of this library will hopefully drop the match method anyways, as symfony will move to matchRequest with PSR-7 or symfony Request.

@dawehner
Copy link
Contributor Author

dawehner commented Dec 5, 2015

Yeah sure, Drupal will find workarounds, this is for sure

@dbu dbu closed this as completed Dec 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants