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.html
Before the Hydrator/exchangeArray 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 Hydration/exchangeArray 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.
// Village
id, name, position, square_id
// Map Square
id, name, type
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?