mark-gerarts / automapper-plus

An AutoMapper for PHP
MIT License
551 stars 30 forks source link

Operation::setTo omits target property if the source property doesn't exist #53

Closed eremem closed 4 years ago

eremem commented 4 years ago

My target class has a property which the source class is lacking. To this target property I would like to be able to assign a particular value during the mapping. According to the documentation Operation::setTo seems to do the job, but at the moment it ignores target properties for which there are no equivalent source properties. Is there any reason behind this behaviour? I looked at the Options object too, but see no relevant setting. I know I could define a callback, but Operation::setTo is way more elegant in this case.

mark-gerarts commented 4 years ago

Yes you are right, this is not the intended behaviour. A fix for this has been pushed, it's available in release 1.3.9. Thanks for reporting!