Access current route name in Slim3 controller's class constructor
<p>With Slim I group my controllers and generally have an abstract BaseController I extend for each group.  I use class based routing:</p>

<pre><code>/* SLIM 2.0 */
// Users API - extends BaseApiController
$app-&gt;post('/users/insert/'   , 'Controller\Api\UserApiController:insert');
.
.
// Campaigns - extends BaseAdminController
$app-&gt;get('/campaigns/', 'Controller\CampaignController:index')-&gt;name('campaigns');
</code></pre>

<p>and needed to password protect some routes, at other times I needed to have a slightly different configuration.  BaseApiController, BaseAdminController... etc.  There were times I needed to know which route I was in so I could execute a certain behavior for just that route. In those cases I would have a helper function like so:</p>

<pre><code>/* SLIM 2.0 */
// returns the current route's name
function getRouteName()
{
    return Slim\Slim::getInstance()-&gt;router()-&gt;getCurrentRoute()-&gt;getName();
}
</code></pre>

<p>This would give me the route name that is currently being used. So I could do something like...</p>

<pre><code>namespace Controller;
abstract class BaseController
{
    public function __construct()
    {
        /* SLIM 2.0 */
        // Do not force to login page if in the following routes
        if(!in_array(getRouteName(), ['login', 'register', 'sign-out']))
        {
            header('Location: ' . urlFor('login'));
        }
    }
}
</code></pre>

<p>I cannot find a way to access the route name being executed. I found this link</p>

<p><a href="https://stackoverflow.com/questions/34476444/slim-3-get-current-route-in-middleware">Slim 3 get current route in middleware</a></p>

<p>but I get NULL when I try</p>

<pre><code>$request-&gt;getAttribute('routeInfo');
</code></pre>

<p>I have also tried the suggested:</p>

<pre><code>'determineRouteBeforeAppMiddleware' =&gt; true
</code></pre>

<p>I've inspected every Slim3 object for properties and methods, I can't seem to find the equivalent for Slim3, or get access to the named route.  It doesn't appear that Slim3 even keeps track of what route it executed, it just... executes it.  </p>

<p>These are the following methods the router class has and where I suspect this value would be:</p>

<pre><code>//get_class_methods($container-&gt;get('router'));

setBasePath
map
dispatch
setDispatcher
getRoutes
getNamedRoute
pushGroup
popGroup
lookupRoute
relativePathFor
pathFor
urlFor
</code></pre>

<p>I was hoping someone has done something similar.  Sure, there are other hacky ways I could do this ( some I'm already contemplating now ) but I'd prefer using Slim to give me this data.  Any Ideas?</p>

<p>NOTE: I'm aware you can do this with middleware, however I'm looking for a solution that will not require middleware.  Something that I can use inside the class thats being instantiated by the triggered route.  It was possible with Slim2, was hoping that Slim3 had a similar feature.</p>