ZF2 - How to use the Hydrator/exchangeArray() to populate a nested object

I've got an object with values that are stored in my database. My object also contains another object which is stored in the database using just the ID of it (foreign key).http://framework.zend.com/manual/2.0/en/modules/zend.stdlib.hydrator.htmlBefore the \[code\]Hydrator/exchangeArray\[/code\] functionality in ZF2 you would use a Mapper to grab everything you need to create the object. Now I'm trying to eliminate this extra layer by just using \[code\]Hydration/exchangeArray\[/code\] to populate my objects but am a bit stuck on creating the nested object.Should my entity have the Inner object's table injected into it so I can create it if the ID of it is passed to my 'exchangeArray' ?Here are example entities as an example.\[code\]// Villageid, name, position, square_id// Map Squareid, name, type\[/code\]Upon sending square_id to my Village's exchangeArray() function. It would get the mapTable and use hydrator to pull in the square using the ID I have.It doesn't seem right to be to have mapper instances inside my entity as I thought they should be disconnected from anything but it's own entity specific parameters and functionality?
 
Top