Agnostic interfaces for a DataMapper implementation through vendor specific adapters

1.0.0 2015-05-18 21:01 UTC

This package is auto-updated.

Last update: 2020-07-11 18:36:31 UTC


Latest Stable Version Latest Unstable Version Build Status Code Coverage Scrutinizer Code Quality

Agnostic interfaces for a DataMapper implementation through vendor specific adapters.


DataMapperManager usage

This library provides an optional Zend Framework 2 plugin manager for DataMapperInterface instances, the DataMapperManager.

It provides a method to retrieve data mappers for your entities: DataMapperManager::getDataMapperForEntity($entity).

Here is an example:

$config = new DataMapperManagerConfig([
    'entity_data_mapper_map' => [
        Entity::class => 'EntityDataMapperServiceName',
    'factories' => [
        'EntityDataMapperServiceName' => function () {
            // return a DataMapperInterface            

$dataMapperManager = new DataMapperManager($config);

// retrieves the service configured as 'EntityDataMapperServiceName'
$entityMapper = $dataMapperManager->getDataMapperForEntity(Entity::class);

To use the DataMapperManager you have to require zendframework/zend-servicemanager via Composer:

composer require zendframework/zend-servicemanager

Usage in a ZF2 module

When using the library as a Zend Framework 2 module, you can load the module Thorr\Persistence and implement DataMapperManagerConfigProviderInterface in your modules to provide the configuration via the getDataMapperManagerConfig() method.

The module will also register in the main ServiceManager a DataMapperManager instance with its FQCN, aliased with the DataMapperManager name, so you can retrieve it as follows:

// or