I'd like to mimic Doctrine Table inheritance (https://the-phpjs-ldc.rgou.net/symfony1/more-with-symfony/en/09-Doctrine-Form-Inheritance.markdown )
I've manage to do it for findFirst method
public static function findFirst($parameters = null)
{
$object = parent::findFirst($parameters);
if (!$object) {
return false;
}
switch ($object->type) {
case 'Offer':
$return = new Offer();
break;
default:
return $object;
}
$return->assign($object->toArray());
return $return;
}
(here we assume that the column type can have an Offer value and we want the model associated to be Offer (which inherit our own class)
It works.
But i don't find a good way to do this for find method, the idea would be to do the same kind on things while iterating in resultset. But how to hook query to return our own resultset and not the ResultSet\Simple ?
Thanks in advance
Olivier