How (and where) to construct an Entity with large number of params?

This is a DDD related question and I'm coding in php.

A user submits a form which contains a large number of values. Some are optional but let's ignore that for now.

So now in the Controller we validate the form data, and assuming the validation was successful, we now we have a named array full of values.

I'm curious of the best way of passing this data through to the domain and where the Value Objects should be created...

One way is to pass the array to an Application Service where the array of values is then deconstructed into variables. At this point some of the variables are pulled together into Value Objects. Then these individual parts (a mix of VOs and scalar data) are sent into the constructor of the Entity I'm eventually trying to create (the point of the form).

But is it ok for this Application Service to receive an array of values? This array is essentially tied to the UI in that the array keys are form input names...

I could break the array down into variables in the Controller but this would result in 20-30 variables being passed about which is obviously stupid.

Also is it ok for this Application Service to do so much with domain objects? It could result in quite a heavy service...

Which leads me to another solution: just pass the array into a Domain Service which breaks the array down, creates VOs and then instantiates the Entity.

But passing an array from a form request into my domain feels inherently wrong too.

This feels like an easy problem but my experience is limited and so any help would be very appreciated.

Thanks!

链接地址: http://www.djcxy.com/p/61456.html

上一篇: 如何使用Laravel Eloquent将多个记录插入数据库

下一篇: 如何(以及在​​哪里)构建一个具有大量参数的实体?