I am currently developing a DDD application and I try to transform a old client project to training myself (Symfony, PHP, Doctrine).
In this app, a user, have a team (a team have lot of users), and a team have a client, client is a company who paid application (one client have lot of teams).
In several parts of the code, I need to do this :
$team = $user->team();
$client = $team->getClient();
Can I create a query in "UserRepository" for example to get User, Team and Client together, to avoid to do 3 different query ?
Multiple business logic need to know lot of things, example :
if ($user->getTeam()->someGet()) {
// logic
} elseif ($user->getTeam()->getClient()->someGet()) {
// logic
} else {
// logic
}
I have this for other entities, in lot of project, service chaining getter
$entityA->getEntityB()->getEntityC()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…