Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing DI container from Radar? #41

Open
cxj opened this issue Dec 2, 2019 · 0 comments
Open

Exposing DI container from Radar? #41

cxj opened this issue Dec 2, 2019 · 0 comments

Comments

@cxj
Copy link
Contributor

cxj commented Dec 2, 2019

@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).

@cxj cxj self-assigned this Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant