ZF2 - ServiceManager injecting into 84 tables… tedious

sophayyyyyyy

New Member
I originally made another thread about this a couple of months ago in regards to ZF2 injecting into tables with DI during Beta 1 and figured back then that it wasn't really possible. Now ZF2 has been released as version 2.0.0 and ServiceManager is defaulted to instead of DI I guess I have the same question now I'm refactoring.I've got 84 tables that need the DbAdapter injecting into them and I'm sure there has to be a better way as I'm replicating myself SO much.\[code\]public function getServiceConfig(){ return array( 'factories' => array( 'accountTable' => function ($sm) { $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $table = new Model\DbTable\AccountTable($dbAdapter); return $table; }, 'userTable' => function ($sm) { $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $table = new Model\DbTable\UserTable($dbAdapter); return $table; }, // another 82 tables of the above ) )}\[/code\]With the EventsManager and ServiceManager I have no idea where I stand in getting my application's instances/resources.Thanks, Dom
 
Top