-
Notifications
You must be signed in to change notification settings - Fork 2.5k
add AdapterManager in to Zend\Db\Adapter namespace #2903
add AdapterManager in to Zend\Db\Adapter namespace #2903
Conversation
I think this all belongs in the Zend\Mvc\Service location. |
@ralphschindler |
Yes, I think both should be moved, they are only useful in an MVC application that consumes the ServiceManager (as described since both of these have dependencies on the ServiceManager). |
* @throws InvalidArgumentException | ||
* @return Adapter | ||
*/ | ||
public function factoryAdapter($config, ServiceLocatorInterface $serviceLocator=null) |
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.
rename to "adapterFactory"
Two additional notes:
|
after the proposal from ralph i tried to solve the dependencies to the ServiceManager package...
@weierophinney |
Is this available for end users (configuring/using multiple databases)? If not could you please point me in the right direction for an intermediate solution? |
@ClemensSahs do you have time to do this in the next 1-2 weeks? If not, I need to change the milestone. @zensys This is a pull request adding the feature; it's not available currently in the master repository. |
Do you have any additional comments here? If not, do you mind if I take this for inclusion in 2.1, my only change is that it resides in the Zend\Mvc\Service namespace as it has dependencies on Zend\Mvc conventions and also promotes a configuration convention. |
@weierophinney @ralphschindler yes i will change some think and will implement unit tests for all |
- patch some coding standards - rename config key from 'db' to 'db_adapter_manager'
@ClemensSahs Feature freeze is in a couple days. I'm going to remove the milestone. If you get it done by then, I'll re-assign it to 2.1. |
add getAdapterConfig
-clean lines with ending space
- fix typo - change the expected Exception for "testWrongAlias"
- fix issue find by "testAdapterDuplicatKey" - fix typo
@weierophinney @zensys |
I'm wondering if The |
To implement the ServiceLocator has only one benefits. Add the ability to use ServiceKeys like aliase. I think a extention of AbstractPluginManager to much for this case. |
Right, but extending the
and not have to reinvent a lot of the stuff you're doing in your manager. |
Sounds nice but overstocked. The main benefit of my PR is a multi db alternative for But I see currently only more complexity. Can you give me a example config for your version like the one in the description? |
Sure: class Module
{
public function getConfig()
{
return array(
'db_adapters' => array(
'adapters' => array(
'module1' => array(
'driver' => 'pdo_mysql',
'username' => 'user',
'password' => 'pass',
),
),
'aliases' => array(
'default' => 'module1',
),
'factories' => array(
'module2' => function ()
{
return new Adapter($driver, $platform);
},
),
),
);
}
}
class IndexController
{
/** @var \Zend\Db\AdapterManager */
protected $adapters;
public function indexAction()
{
$adapter = $this->adapters->get('default');
}
} |
@radnan refactoring in progress for Unit-Test and Exceptions PS: the methodes I mean
any feedback? |
@ClemensSahs I find your patch pretty interesting. |
* @var Adapter[] | ||
*/ | ||
protected $_dbAdapter = array(); | ||
|
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.
Don't prefix non-public members with underscores; no longer needed with ZF2 CS.
I'd like to humbly submit my take on the issue: |
@radnan but on this way we don't can customizes "plattform objects" and "result prototype" |
I am going to close this PR. The idea is good, but this particular implementation is not what needs to happen. Probably @radnan's implementation is closer, if he were to move it into the Zend\Mvc namespace. From there I think we can open an new PR when that one is ready. |
this AdapterManger allows handle multible database connections and aliase
unit tests will follow