Config

How to use Shard extensions inside zf2

Configuring DoctineModule and DoctrineMongoODMModule

DoctrineModule and DoctrineMongoODMModule are maintained by the Doctrine project for integrating Doctrine Mongo ODM with zf2. They provide their own configuration documentation. Use these modules to configure a DocumentManager and possibly other services, such as an AuthenticationAdapter. Shard Module will use the services configured by these modules.

Specify which Shard Extensions you want to use.

Shard Module supports multiple DocumentManager-Manifest pairs. Each manifest needs to be configured with a document manager, and the extensions you want to use. Eg:

'zoop' => [
    'shard' => [
        'manifest' => [ //Array of different manifests. (Most of the time you'll only use one)
            'default' => [ //The manifest name
                ... //Put the manifest config in here
            ]
        ]
    ]
]

Note, that the value of document_manager in the manifest config can be the name of the document manager service configured by DoctrineMongoODMModule.

Example complete config (with three extensions turned on):

'zoop' => [
    'shard' => [
        'manifest' => [
            'default' => [
                'document_manager' => 'doctrine.odm.documentmanager.default',
                'extension_configs' => [
                        'extension.accessControl' => true,
                        'extension.freeze' => true,
                        'extension.owner' => true,
                ],
            ]
        ]
    ],
]

All other config keys in a manifest configuration are supported. See shard docs.

User Config

Shard Module will automatically configure a shard manifest to use any object returned by $serviceLocator->get(Zend\Authentication\AuthenticationService)->getIdentity() as the user.

If you would like to use zend authentication integrated with Doctrine and Shard's access control, then take a look at Gateway Module.

Use services provied by Shard Extensions.

Many Shard extensions provide services. To access those services through the main application service manager, just prefix the service name with shard.$manifestName.. Eg:

$serializer = $serviceLocator->get('shard.default.serializer');
//and
$accessController = $serviceLocator->get('shard.default.accessController');