I'm wondering whether it's possible to make a custom Doctrine proxy or similar which would allow me to lazy load an Entity's property from a service.
EXAMPLE:
class Article {
...
/** @ORM\Column(type=integer) **/
protected $userId;
/** @var /MyUser **/
protected $user;
}
$user property is not handled by doctrine. Users are fetched through a DI service which connects to a web service. What I would like to do is hook into doctrine so when $article->user is used the object is lazy loaded using the custom defined DI service.
Any idea whether that is possible?
If lazy loading is not possible, would it be possible to hook into the postLoad event and load the user object using the predefined service?