Help on object clone
disu opened this issue · 0 comments
disu commented
Hello,
I need to add to my software a function to clone an entity containing the upload behavour configured to save files on S3.
I use a code like this pseudo-code and it works well duplicating main entity (Ship) and absociated models (Ship documents, in this example):
$ship = $this->Ships->get($id, ['contain' => ['ShipsDocs']]);
$data = $ship->toArray();
$data['name'] = $ship->name . " - copy";
$newShip = $this->Ships->newEntity($data, [
'associated' => ['ShipsDocs'],
]);
but how can I trigger the upload behaviour to clone also files on S3, absociated to the source entity, and absociate the new ones to the cloned entity?
Give me some hint please.