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

After new update ServerRequestInterface returning incorrect object #218

Closed
andrew-svirin opened this issue Dec 9, 2021 · 6 comments
Closed
Labels

Comments

@andrew-svirin
Copy link

request model become work wrong

public function view(ServerRequestInterface $request): ResponseInterface {
        $response = $this->responseFactory->createResponse();

        $id = (int)$request->getAttribute('id');
        // Here error. Function return null, but before returned value.
        // Method GET.
@andrew-svirin
Copy link
Author

I see you stop using yiisoft/yii-web and change on yiisoft/yii-http, but it requires PHP 8.0

@andrew-svirin
Copy link
Author

andrew-svirin commented Dec 9, 2021

Found how to avoid ServerRequestInterface $request->getAttribute(). Using CurrentRouteInterface $currentRoute->getArgument('id') it responding value, for this moment.

@rustamwin
Copy link
Member

rustamwin commented Dec 9, 2021

Yes, route arguments have been moved to CurrentRouteInterface.

@andrew-svirin
Copy link
Author

andrew-svirin commented Dec 9, 2021

but, then remove method getArguments from ServerRequestInterface @rustamwin

@samdark
Copy link
Member

samdark commented Dec 9, 2021

You mean getAttributes()? This is PSR and we cannot modify it. The meaning of it is not to get router's parameters but to pass data from one middleware to another in a middleware stack.

I'll update that in the docs closer to release.

@andrew-svirin
Copy link
Author

Understood, this buffer to transfer data via middleware into action.
It is good idea to divide router and request data.

Thanks for answer =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants