flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.61k stars 407 forks source link

Dispatcher refactor #540

Closed fadrian06 closed 5 months ago

fadrian06 commented 5 months ago

Before:

Dispatcher::run(...)

// run pre filters
// ...

// run requested method
// ...

// run post filters
// ...

After

$this->runPreFilters(...);
$this->runEvent(...);
$this->runPostFilters(...);

Next refactor I want that it will be:

$event = $this->events->get($eventName);

// Events::__invoke() will call pre filters and post filters
return $event(...$params);
fadrian06 commented 5 months ago

If you accept this refactor, please

don't delete the branch to add Events::class and Filters::class in another refactor.

fadrian06 commented 5 months ago

image image