simple-php-router icon indicating copy to clipboard operation
simple-php-router copied to clipboard

Make current processing rule accessible

Open xJuvi opened this issue 3 years ago • 1 comments

With this PR i want to resolve my bad solution from #598

I added a new global variable which will contains the current processing rule while processing. So the data (like rule name) are usable in the middleware:

namespace My\Router\Namespace;

use Pecee\Http\Middleware\IMiddleware;
use Pecee\Http\Request;
use Pecee\SimpleRouter\SimpleRouter as Router;

class test implements IMiddleware
{
	public function handle(Request $request) : void
	{
		$router = Router::router();
		$RouteName = $router->getCurrentProcessingRoute()->getName();
	}
}

Thanks for merging.

Kind regards

xJuvi avatar Jan 02 '22 14:01 xJuvi

waiting to merge this good work!

Clrkz avatar Sep 12 '22 05:09 Clrkz

hi @Clrkz

i changed the repo to this fork: https://github.com/DeveloperMarius/simple-php-router/tree/v5-development-php8

There are some fixes for php8 and many other things. The most of open PRs from this project were merged in the forked repo, this PR also.

Kind regards

xJuvi avatar Oct 23 '22 08:10 xJuvi