Open karimkawambwa opened 9 years ago
Yea, this is something I have planned for a later version. Unfortunately, it would break backwards compatibility pretty heavily, as all route callbacks would have to have their signatures changed, so its going to have to wait until the next major version.
@Rican7,
I was just wandering if a simple if/else could be used.
if (true === $this->passKleinToCallback) {
$returned = call_user_func(
$route->getCallback(),
$this,
$matched,
$methods_matched
);
} else {
// Handle the callback
$returned = call_user_func(
$route->getCallback(), // Instead of relying on the slower "invoke" magic
$this->request,
$this->response,
$this->service,
$this->app,
$this, // Pass the Klein instance
$matched,
$methods_matched
);
}
It's not pretty, but it works. If you do want do this, let me know and I'll create a pull request.
I'd rather not introduce more configurable branching for now. Klein already has a lot of branching based on configurations and injectables. I might introduce an interesting way to do this in a refactor that I'm current working on. We'll see.
@Rican7 Fair enough.
Just for helping coding style, can the function variables be returned in and single object. Eg.
is really long, if i only just want to get $app. So can this be made better by perhaps having them all in one object parameter e.g.
or
or which ever way is better.