Multi module / registerAutoloaders used config in bootstrap
W \ Phalcon \ Mvc \ ModuleDefinitionInterface -> registerAutoloaders should be shared di or registerAutoloaders method should not be required.
If you are in the config path we leave registerAutoloaders currently empty and registerNamespaces used in registerServices in order to be used in the config bootstrap (index.php)
public function registerAutoloaders($di) { ... }
I am not sure that I understand this correctly.
You are saying that we should not use the registerAutoloaders in the interface?
What if you need to register an autoloader specific to that module?
You can always (when implementing your interface) leave that function empty and Phalcon will not execute it.
Can you please explain what you mean by the config path?
- Declare config ini file.
- Loading it in the bootstrap ($ d-> set (config, ...))
- I am part of the bootstrap.
- Transfers to the module
- Creating a namespace on the basis config ($ d-> get (config))
Manual says that in registerAutoloaders () (ModuleDefinitionInterface) add namespace and there I do not have access to the $ d to get config.
So you need to: registerAutoloaders () - leave blank and registerServices () can add, at this moment registerAutoloaders method () is not needed.
solution: registerAutoloaders () - not required registerAutoloaders () - has passed $ d -> registerAutoloaders (di)
If you're using 0.8.0, the $di is passed to registerAutoloaders, however you can use an anonymous function if you don't want to implement the Module definition class:
<?php
// Register the installed modules
$application->registerModules(
array(
'frontend' => function($di) {
//...
},
'backend' => function($di) {
//...
}
)
);