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

[Routing] Also copy the Host in the Router::match #1620

Merged
merged 1 commit into from
Jan 8, 2018

Conversation

lyrixx
Copy link
Contributor

@lyrixx lyrixx commented Dec 28, 2017

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

BTW, we could just clone the context, and replace few information:

    public function match($pathInfo)
    {
        $baseContext = $this->router->getContext();
        $pathInfo = str_replace($baseContext->getBaseUrl(), '', $pathInfo);

        $context = clone $baseContext;
        $context->setMethod('GET');
        $context->setPathInfo($pathInfo);

        $this->router->setContext($context);
        try {
            return $this->router->match($pathInfo);
        } finally {
            $this->router->setContext($baseContext);
        }
    }

Why do I hit all the bugs :/

@dunglas
Copy link
Member

dunglas commented Dec 28, 2017

The clone hack looks more future-proof. 👍 to use it.

@dunglas dunglas merged commit 7d0e831 into api-platform:2.0 Jan 8, 2018
@dunglas
Copy link
Member

dunglas commented Jan 8, 2018

Merging this one for now, feel free to open another PR to clone instead. Thanks @lyrixx!

@lyrixx lyrixx deleted the router branch January 9, 2018 09:34
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
[Routing] Also copy the Host in the Router::match
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

Successfully merging this pull request may close these issues.

None yet

3 participants