router icon indicating copy to clipboard operation
router copied to clipboard

Inconsistent \Yiisoft\Router\CurrentRoute

Open xepozz opened this issue 1 year ago • 2 comments

Due to \Yiisoft\Router\CurrentRoute doesn't have any restrictions it may be created with $container->get(), but it has whole empty state: image

It's unexpected and cause lots of if's over it. Isn't it better to add RouteProvider with the getCurrent() method that will return either CurrentRoute or Route or throw an exception because it wasn't set before?

xepozz avatar Feb 11 '23 13:02 xepozz

Returns CurrentRoute|Route is confused.

By fact, CurrentRoute is RouteProvider.

vjik avatar Feb 11 '23 14:02 vjik

It's not a provider by design.

xepozz avatar Feb 11 '23 14:02 xepozz