cakephp-upload icon indicating copy to clipboard operation
cakephp-upload copied to clipboard

Help on object clone

Open disu opened this issue 2 years ago • 0 comments

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.

disu avatar Aug 30 '23 17:08 disu