Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
226 views
in Technique[技术] by (71.8m points)

php - DDD : Can repositories return multiple entities/aggregat?

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()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...