Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

add getRouter() function in Routers #134

Closed
wants to merge 2 commits into from

Conversation

samsonasik
Copy link
Contributor

I think this may be useful to add getRouter() so in real app we can use more function from it's router property when needed.

@bakura10
Copy link
Contributor

Maybe renaming it to getInnerRouter ? $router->getRouter() is a bit misleading.

@weierophinney
Copy link
Member

Can you provide some use cases? DI should obviate the need to do that, and
usage of containers with delegator functionality will allow configuration
after normal creation...
On Sep 16, 2015 2:47 PM, "Abdul Malik Ikhsan" [email protected]
wrote:

I think this may be useful to add getRouter() so in real app we can use

more function from it's router property when needed.

You can view, comment on, or merge this pull request online at:

#134
Commit Summary

  • add getRouter() in Routers

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#134.

@samsonasik
Copy link
Contributor Author

@bakura10 I can rename to that of course if it accepted
@weierophinney for example: I need to call generateRaw() as I uses Aura\Router\Router, We can already inject the middleware with Zend\Expressive\Router\RouterInterface::class as service, and from the router injected, I can call $this->router->getRouter()->generateRaw('routename')

@weierophinney
Copy link
Member

How is generateRaw() different from generateUrl()? This may be an
indication that we need an additional method in the router interface...
On Sep 19, 2015 12:12 PM, "Abdul Malik Ikhsan" [email protected]
wrote:

@bakura10 https://github.com/bakura10 I can rename to that of course if
it accepted
@weierophinney https://github.com/weierophinney for example: I need to
call generateRaw() as I uses Aura\Router\Router, We can already inject
the middleware with Zend\Expressive\Router\RouterInterface::class as
service, and from the router injected, I can call
$this->router->getRouter()->generateRaw('routename')


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

@samsonasik
Copy link
Contributor Author

generateRaw() generate the route without url encoding. Add addiitonal method in interface for what ? getRouter() or generateRaw() ? I agree for getRouter, but If generateRaw(), then we need to maintain for different adapters.

@weierophinney
Copy link
Member

I'm thinking we should assume that router implementations return unencoded (raw) URIs, and that users should encode manually, after retrieval, when necessary. I'd argue that this path would be best, as the original data is typically easy to get, and applying an escaping mechanism to it after-the-fact based on context would allow keeping the encoding functionality completely out of the RouterInterface functionality.

As such, I'd argue that we need a patch that does the following:

  • Stipulates in the generateUri() docblock that the URI returned MUST NOT be encoded.
  • Updates the Aura.Router implementation to use generateRaw() internally.

Does that seem reasonable @samsonasik ?

@samsonasik
Copy link
Contributor Author

my initial idea about it is not about specific generateRaw(), it was just in case we need to call another method from the internal router, we can call via getRouter() or getInternalRouter() without need to extends existing router adapter.

@weierophinney
Copy link
Member

In that case, you're depending on a specific, concrete adapter, and you
might as well inject your object with the underlying router if you need
that functionality.
On Oct 9, 2015 11:37 PM, "Abdul Malik Ikhsan" [email protected]
wrote:

my initial idea about it is not about specific generateRaw(), it was just
in case we need to call another method from the internal router, we can
call via getRouter() or getInternalRouter() without need to extends
existing router adapter.


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

@samsonasik
Copy link
Contributor Author

ok ;)

@samsonasik samsonasik closed this Oct 11, 2015
@samsonasik samsonasik deleted the add-get-router branch October 11, 2015 01:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants