Skip to content

Instantly share code, notes, and snippets.

@nclundsten
Created March 27, 2013 07:06
Show Gist options
  • Save nclundsten/5252337 to your computer and use it in GitHub Desktop.
Save nclundsten/5252337 to your computer and use it in GitHub Desktop.
example for: service manager key: 'shared'
<?php
return array(
'invokables' => array(
'my_uninitialized_mapper' => 'Module\Mapper\MyMapper',
),
'factories' => array(
'some_table_mapper' => function ($sm) {
$mapper = $sm->get('my_uninitialized_mapper');
$mapper->setTableName('some_table');
$mapper->setDbAdapter($sm->get('module_db_adapter'));
},
'other_table_mapper' => function ($sm) {
$mapper = $sm->get('my_uninitialized_mapper');
$mapper->setTableName('other_table');
$mapper->setDbAdapter($sm->get('module_db_adapter'));
},
),
/*
* in the factories above, both returned instances start with the same
* uninitialized mapper, but have different table names
* this would cause issues if you did not disable sharing.
*/
'shared' => array(
'my_uninitialized_mapper' => false, //default is true
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment