Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Provide a dedicated service for server request error response generation#562

Merged
weierophinney merged 5 commits intozendframework:release-3.0.0fromweierophinney:hotfix/use-constants-not-virtual-services
Feb 22, 2018
Merged

Provide a dedicated service for server request error response generation#562

weierophinney merged 5 commits intozendframework:release-3.0.0fromweierophinney:hotfix/use-constants-not-virtual-services
Feb 22, 2018

Conversation

@weierophinney
Copy link
Member

@weierophinneyweierophinney commentedFeb 22, 2018
edited
Loading

Provide a dedicated service for the server request error response generator

Instead of re-using the existingErrorResponseGenerator, this patch does the following:

  • Separates functionality for generating the error response into a trait,Zend\Expressive\Response\ErrorResponseGeneratorTrait. The methodprepareTemplatedResponse() now expects the error, the response, and an array of data to provide to the template.
  • UpdatesZend\Expressive\Middleware\ErrorResponseGenerator to use the new trait.
  • Creates a new class,Zend\Expressive\Response\ServerRequestErrorResponseGenerator, which expects a response factory, and optionally the debug flag, renderer, and template to render to. It composes the trait, and generates a response on-the-fly to pass to the trait methods.

TheRequestHandlerRunnerFactory has been updated to use this new service, and theServerRequestErrorResponseGeneratorFactory was updated to generate an instance of the new class.

These changes mean the constant SERVER_REQUEST_ERROR_RESPONSE_GENERATOR is no longer needed, and was thus removed.

Copy link
Member

@michalbundyramichalbundyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM 👍

I had a hope we can avoid using constants at all...

@weierophinneyweierophinney changed the titleUse the SERVER_REQUEST_ERROR_RESPONSE_GENERATOR constantProvide a dedicated service for server request error response generationFeb 22, 2018
@weierophinney
Copy link
MemberAuthor

@webimpress Please re-review; this removes the constant, and provides a dedicated service.

public function __invoke(Throwable $e)
{
$response = ($this->responseFactory)()
->withStatus(Utils::getStatusCode($e, $response));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

$response is not yet defined so can't be used here.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good catch - and demonstrates I need to fully test this class. I'll push more commits momentarily.

…eratorInstead of re-using the existing `ErrorResponseGenerator`, this patchdoes the following:- Separates functionality for generating the error response into a  trait, `Zend\Expressive\Response\ErrorResponseGeneratorTrait`. The  method `prepareTemplatedResponse()` now expects the error, the  response, and an array of data to provide to the template.- Updates `Zend\Expressive\Middleware\ErrorResponseGenerator` to use the  new trait.- Creates a new class, `Zend\Expressive\Response\ServerRequestErrorResponseGenerator`,  which expects a response factory, and optionally the debug flag,  renderer, and template to render to. It composes the trait, and  generates a response on-the-fly to pass to the trait methods.The `RequestHandlerRunnerFactory` has been updated to use this newservice, and the `ServerRequestErrorResponseGeneratorFactory` wasupdated to generate an instance of the new class.These changes mean the constant SERVER_REQUEST_ERROR_RESPONSE_GENERATORis no longer needed, and was thus removed.
Corrects an issue in the default message when a stack trace is producedas well.
Updates the methods of the `ErrorResponseGeneratorTrait` to accept therenderer and debug flag as arguments instead of relying on internalstate; this ensures that they are of the type expected.Updated both implementations to pass the new arguments.
@weierophinneyweierophinney merged commit457bc1f intozendframework:release-3.0.0Feb 22, 2018
@weierophinneyweierophinney deleted the hotfix/use-constants-not-virtual-services branchFebruary 22, 2018 20:49
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

1 more reviewer

@michalbundyramichalbundyramichalbundyra approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@weierophinney@michalbundyra

[8]ページ先頭

©2009-2025 Movatter.jp