I'm building an CMS with zend framework 2. I have 2 questions and hope you can help me.
- My module uses many different SQL tables. Following the example in skeleton-application, I have to do like this:
public function getServiceConfig() {
return array(
'factories' => array(
'Album\Model\AlbumTable' => function($sm) {}, 'AlbumTableGateway' => function ($sm) {}, 'Album\Model\Trackable' => function($sm) {}, 'TrackTableGateway' => function ($sm) {}, 'Album\Model\ArtistTable' => function($sm) {}, 'ArtistTableGateway' => function ($sm) {}, 'TrackTableGateway' => function ($sm) {}, 'Album\Model\SingerArtistTable' => function($sm) {}, 'SingerTableGateway' => function ($sm) {}, ... ), ); }
So should I put many models in gServiceConfig() like above? Or can you suggest me any other patterns?
- I want to ask when we use "fatories" in getServiceConfig, is it true that the model will be initialized only when we call it? Thank you so much for your reply!