Radar.Adr
Radar.Adr copied to clipboard
Exposing DI container from Radar?
@pmjones What do you think of providing a way to access the DI container via the Radar\Adr\Adr
instance returned by the Radar\Adr\Boot::boot()
method? I'm thinking this is parallel to the access provided to Aura\Route
.
I'm just looking for your philosophical opinion here on the appropriateness of doing this, or what an alternative might be. I'm happy to write the code.
I need something like this because of how we initialize our route maps via Radar from a top-level file, e.g. index.php
. For example, this works, but means I've created 2 DI containers, and that the configuration file is getting read/parsed twice to set the DI values used within it (in my case, URLs for associated web sites):
$boot = new Boot();
$adr = $boot->adr(['Clx\Web\_Config',]);
$diBuilder = new ContainerBuilder();
$di = $diBuilder->newConfiguredInstance(['Clx\Web\_Config',]);
$routes = $di->newInstance(Routes::class);
$routes->setRoutes($adr);
The Routes
class above is my local class which contains all of these sorts of calls:
$adr->get('/', '/', App\AnonApp::CLASS)
->responder(LoginResponder::class)
->extras(['tss' => $site . '/login']);
The whole reason for having the second DI is so that I can get the $site
value injected from the exact same config file specified in Clx\Web\_Config
.
If I could instead do something like this, maybe it would make sense and be more usable:
$routes = $adr->newInstance(Routes::class);
And have Radar proxy that through to my DIC (Aura Di in this case).