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

Add support to prepend handler #587

Closed
filips123 opened this issue Jul 7, 2018 · 6 comments
Closed

Add support to prepend handler #587

filips123 opened this issue Jul 7, 2018 · 6 comments

Comments

@filips123
Copy link

filips123 commented Jul 7, 2018

Add support to prepend handler. When using this, handler should be added before other handlers. Also, don't forget to update RunInterface with new function.

I found simple solution:

public function prependHandler($handler)
{
    $existingHandlers = array_merge([$handler], $this->getHandlers());
    $this->clearHandlers();

    foreach ($existingHandlers as $existingHandler) {
        $this->pushHandler($existingHandler);
    }
}
@denis-sokolov
Copy link
Collaborator

The users of Whoops can perform this operation themselves if they need it. I believe most of the users will never encounter this situation, so I don’t think there’s a lot of valu in adding this feature. Change my mind if you have specific use cases!

@filips123
Copy link
Author

I could be used if program first add some general handlers, but prepend additional handler under certain condition (maybe for additional debugging or other operations).

@denis-sokolov
Copy link
Collaborator

Thanks! I think for now we can afford to make the users perform the operation themselves. If we later see more use cases for this popup, we’ll revisit!

@filips123
Copy link
Author

Ok. Do you have any solution how can users prepend handler themselves? My solution above could be inefficient because it needs to remove and then re-add all handlers.

@denis-sokolov
Copy link
Collaborator

Your solution above is absolutely adequate! I doubt you’ll measure a noticable impact on performance at all.

@denis-sokolov
Copy link
Collaborator

#630 has just added this, released in 2.4.0.

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 a pull request may close this issue.

2 participants