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

Add a way to get a hand on a cloned object #124

Open
GregOriol opened this issue Aug 24, 2018 · 2 comments
Open

Add a way to get a hand on a cloned object #124

GregOriol opened this issue Aug 24, 2018 · 2 comments

Comments

@GregOriol
Copy link

We have a situation where we have objects that are somehow linked to other structures (an object references a file on disk in our case). When the deep copy of a data tree is performed, the objects are cloned inside, but we also need a hand on the old and new objects together to be able to copy the associated structure at the same time (cp files on disk here).

I don't see a way to do that currently, we thought about the type filter/type replace but we don't want to "manually" clone the object as would be with this filter, we are perfectly good with the normal cloning, we just need to know when one was cloned to perform the additional operations we need.

What would be the best way to do it? Events? Callbacks? Type filters that can be chained?

@theofidry
Copy link
Collaborator

what about the regular __clone for the object encapsulating that file? DeepCopy can use it instead of performing a deep clone so that regular objects would have your custom behaviour

@GregOriol
Copy link
Author

@theofidry I want the deep clone behavior (mostly because the data is doctrine entities), but also would like to be able to perform something after the cloning of some of the objects in the data tree

__clone would do something like that, but it would remove the deep cloning and I wouldn't use deepcopy if I could just go with the standard clone :-)

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