-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Added database adapter abstract service factory. #3933
Added database adapter abstract service factory. #3933
Conversation
Change-Id: I35ed79abc898088c50d40467d6e64726e433e9f7
if (isset($config['db'][$name])) { | ||
return new Adapter($config['db'][$name]); | ||
|
||
} else if (isset($config['db'][$requestedName])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should :
- no use "elseif" because you have check with "canCreateServiceWithName"
- throw exception after "elseif"
But should not return null ?
method. Change-Id: Ia6882123128c1752151f4c4560cb8d1fcb57efa5
@blanchonvincent, redundant code removed. |
@Stephanoff ok, now you must add unit tests with the PR |
Change-Id: Id77938e0298d3b214c40db7f2325f5b1efd14d81
@blanchonvincent Test case added. |
This doesn't belong in the Zend\Db namespace, it really belongs in the Zend\Mvc namespace. Please see this discussion: #2903 |
@ralphschindler Should I move AdapterAbstractServiceFactory to MVC namespace or my PR rejected? |
I would think we should just move the files, and keep this PR open. I'd like to also address the previous work that was done one creating a service factory for Db in the other PR. |
@ralphschindler Could you please provide FQCN for the AbstractClass since I'm new with ZF2 conventions. Thanks. |
@ralphschindler I think it's good because : |
Improved validation for existing adapter configuration. Updated unit test. Change-Id: I2ae710320d34a2fb888fcce49969cb776b27b5a7
@ralphschindler I've been doing a lot of thinking about whether or not these factories should be in the individual components, or in It's not unlikely that a developer will want to use the factories outside of the MVC system. If we have the factories in
As such, I plan to merge this to the develop branch for 2.2.0. |
Merged. |
Is there a sample code snippet on how to implement this update? Thanks. |
array(
'db' => array(
'adapters' => array(
'Zend\Db\Adapter\Master' => array(
'driver' => 'mysqli',
),
'Zend\Db\Adapter\Slave' => array(
'driver' => 'mysqli',
),
),
),
'service_manager' => array(
'abstract_factories' => array(
'Zend\Db\Adapter\AdapterAbstractServiceFactory',
),
),
) |
Hi Chellai, You are right, 'ims_db' should be adapter name, this allow access to Best regards, On Thu, May 16, 2013 at 11:24 AM, Chellai Fajardo
|
Hi Andrew, I finally made it worked. Thanks to you. 👍 |
Added database adapter abstract service factory to configure multiple database adapters for application. This abstract factory reserved db.adapters key in configuration array.