How to get RobotLoader from DI\Container?

Notice: This thread is very old.
juzna.cz
Member | 248
+
0
-

Since RobotLoader is now created by Configurator prior to creating the context, it's not available as a service anymore. However, I need it as a service, because other services need it (as their dependency).

Now I get error:
No service of type Nette\Loaders\RobotLoader

Can the Configurator pass created instance of RobotLoader into cotext being created? Thanks

HosipLan
Moderator | 4668
+
0
-
function getRobot()
{
	foreach (Nette\Loaders\AutoLoader::getLoaders() as $loader) {
		if ($loader instanceof Nette\Loaders\RobotLoader) {
			return $loader;
		}
	}
}
juzna.cz
Member | 248
+
+2
-

But I need it to be available in the SystemContainer.

I added robot loader service into config.neon:

		robotLoader:
			class: Nette\Loaders\RobotLoader
			setup:
				- setCacheStorage

And then I attach existing instance in bootstrap.php:

$robotLoader = $configurator->createRobotLoader() ....;
...
$context = $configurator->createContainer();
$context->addService('robotLoader', $robotLoader);

This seems to work fine