Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping operations without source property required #8

Closed
ed-posinitskiy opened this issue Oct 31, 2017 · 3 comments
Closed

Mapping operations without source property required #8

ed-posinitskiy opened this issue Oct 31, 2017 · 3 comments

Comments

@ed-posinitskiy
Copy link

There is a @TODO on AutoMapperPlus\Configuration\Mapping::shouldCheckForSourceProperty() method.

Indeed certain operations needs extra Interface to skip property existence check.

For instance, I don't want certain properties to be mapped into destination object. The way it works now is perfect (with Ignore operation) but there is one problem: when I specify this operation on virtual property (i.e. in Laravel there is a lot of magic happens on models) forMember method will try to ensure source property exist. But it has no sense due to meaning of Ignore operation.

Also you have great PropertyAccessorInterface object, please utilize it to check property can be reached instead of default PHP function within forMember method.

Thanks in advance, great Tool!

@mark-gerarts
Copy link
Owner

Yes, these are very valid points. In fact, as a short term solution I removed the checking of source properties entirely a few days ago, in a9e5590. This isn't part of release yet though, it's only available on dev-master. So if this is causing you problems, you can check out this version for now.

The reason for removing this behaviour is indeed because it doesn't really work with dynamic properties. For the long term it might be better to work with an interface or something similar. but this will require some more thought.

@ed-posinitskiy
Copy link
Author

Thank you for such a quick response! As a workaround I made a custom Operation extended from MapFrom operation to skip property check.

@ed-posinitskiy
Copy link
Author

Thanks for update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants