Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Expose package as a config-provider / ZF component
Browse files Browse the repository at this point in the history
Adds:

- `ConfigProvider`, which maps the `AdapterInterface` service to the
  `AdapterServiceFactory`, and enables the
  `AdapterAbstractServiceFactory`.
- `Module`, which does the same for a zend-mvc context.
  • Loading branch information
weierophinney committed Apr 12, 2016
1 parent c50a3e1 commit b03f028
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"branch-alias": {
"dev-master": "2.7-dev",
"dev-develop": "2.8-dev"
},
"zf": {
"component": "Zend\\Db",
"config-provider": "Zend\\Db\\ConfigProvider"
}
},
"autoload-dev": {
Expand Down
40 changes: 40 additions & 0 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @link http://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Db;

class ConfigProvider
{
/**
* Retrieve zend-db default configuration.
*
* @return array
*/
public function __invoke()
{
return [
'dependencies' => $this->getDependencyConfig(),
];
}

/**
* Retrieve zend-db default dependency configuration.
*
* @return array
*/
public function getDependencyConfig()
{
return [
'abstract_factories' => [
Adapter\AdapterAbstractServiceFactory::class,
],
'factories' => [
Adapter\AdapterInterface::class => Adapter\AdapterServiceFactory::class,
],
];
}
}
24 changes: 24 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* @link http://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Db;

class Module
{
/**
* Retrieve default zend-db configuration for zend-mvc context.
*
* @return array
*/
public function getConfig()
{
$provider = new ConfigProvider();
return [
'service_manager' => $provider->getDependencyConfig(),
];
}
}

0 comments on commit b03f028

Please sign in to comment.