我正在使用ZF2和Doctrine2構建應用程序。 理念是有一個基本的應用程序實體(讓我們稱之爲UserEntity)。Doctrine 2模塊化應用與實體替換
但是在一個模塊A中,我將擁有另一個UserEntity-like實體,它將用新字段「升級」基本實體。另一個模塊B將添加更多的字段。
例:
BaseUserEntity { 保護的$ id; // ... }
ModuleAUserEntity擴展了BaseUserEntity { protected moduleAId; }
ModuleBUserEntity extends BaseUserEntity { protected moduleBUserName; }
是否有可能以某種方式獲得方法,因此當我調用UserEntity時,它將返回完整的,由模塊升級的實體?例如:
UserEntity { protected $ id; // ... protected moduleAId; protected moduleBUserName; }
是否有另一種方法來實現這樣的事情?是否可以「擴展」一個實體?