I am trying to register a custom database loader.
For this, I was inspired by: Submission of the Zend Translator
I have the following factual code in (module.config.php):
'service_manager' => array( 'factories' => array( 'translator' => function($sm){ $translator = new \V1\Service\DatabaseTranslationService(); return $translator->createService($sm); }, ), ),
DatabaseTranslationService looks like this:
$config = $serviceLocator->get('Config'); $trConfig = isset($config['translator']) ? $config['translator'] : array(); $translator = new \Zend\I18n\Translator\Translator(); $translator->getPluginManager()->setInvokableClass('database', '\Foo\I18n\Translator\Loader\DatabaseTranslator', true); $translator->addTranslationFile('database', 'en_EN'); return $translator;
But it looks like "setInvokableClass" is not used: I got this error:
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for database
Does anyone know how to correctly register a translator
source share