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

Possibility to map on destination object for Deep array object mapping #19

Open
furang opened this issue Sep 15, 2021 · 0 comments
Open

Comments

@furang
Copy link

furang commented Sep 15, 2021

The problem:
I have Order and Product entities in doctrine (One Order has Many Products). I receive Order object from api (not Order entity) with Products inside (also not doctrine entity). And i want to update data in db.
For Order I can check it in DB, get and map changes on existing Order entity (I can pass existing entity as $destination).

...
$order = $this->orderRepository->findOneBy([
    ...
]);

if (null === $order) {
    $order = new Order();
}
$this->mapper->map($orderData, $order);
...

But for products all I can do is just

....
->filter('products', new ArrayObjectMappingFilter(Product::class))
....

And this creates new unmanaged entities. And I want to map data to existing products. Is it possible? Or mb you can give me a hint how it can be implemented.

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

1 participant