Open raivirtual opened 5 years ago
I did my workaround adding the invokable method to my own AdapterServiceFactory:
That is how Service Manager expects factories to be. Depending on how you configured your service manager, this is not be a problem. I am guessing you have
invokables => [ RVMvp\Db\Adapter\AdapterServiceFactory::class]
somewhere in your module confugration?
But it's not calling by Service Manager. It's instancing directly.
Hello @raivirtual , You should define a factory for the adapter interface:
'dependencies' => [
//...
'factories' => [
//...
\Zend\Db\Adapter\AdapterInterface::class => \My\Db\AdapterFactory::class,
//...
],
//...
],
In servicemanager config the Zend\Db\Adapter\Adapter::class
service name is actually an alias for Zend\Db\Adapter\AdapterInterface::class::class
(see ConfigProvider in zend-db), but you should build your dependencies upon the AdapterInterface::class
interface as service name.
kind regards
This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/21.
I created my own
Db\Adapter\AdapterServiceFactory
so I could be able to call my ownDb\Adapter
.It should create a service of
RVMvp\Db\Adapter\Adapter
but keep creatingZend\Db\Adapter\Adapter
.This is happening because the invokable method is calling directly the
Zend\Db\Adapter\Adapter
instead of the requested name provided oncreateService
method:I did my workaround adding the invokable method to my own
AdapterServiceFactory
:I'm suggesting a bugfix so we don't need to override the invokable method.