mercredi 17 août 2016

Dynamically extend User entity in symfony

I have the following scenario:

  • My project has an AppBundle with a User entity.
  • Other bundles add more entities like Address, Todo, Project, WhatEver.
  • Those entities must belong to a User so that I can call $user->getAddresses(), $user->getTodos(), $user->addProject(), $user->setWhatEvers().
  • Those bundles must remain "pluggable" so the User entity doesn't necessarily know about them and I can't add those properties like todos and its getters/setters directly into the User entity.

I thought about reflection, magic getters/setters, traits as possible aproaches but nothing really fits my needs. Any ideas on how to achieve this?





Aucun commentaire:

Enregistrer un commentaire