Announcement

Collapse
No announcement yet.

Clone Entity

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Clone Entity

    Hi,

    i need to clone a entity (i know is bad) .. but i just need clone all attribute :
    sample

    entityA {
    name => "blabla",
    assignedUser => "bb",
    teams => ['teamA' , 'teamB'],
    accountId => '123'

    }

    so i need :

    newEntity = clone entityA

    newEntity-set([
    'name' => 'newName'
    'accountId' => '222'
    ]).
    saveEntity->(newEntity).

    it's possible ? i change only 2 attribute.

    Resume : i will not write by hand all attribute.





  • #2
    Hello item

    Unfortunately the only way that I think you can clone an entity (actually a new database table) is to follow eymen-elkum tutorial.

    You will basically need to reproduce everything that the entity manager does when you create a new entity.

    Best Regards
    Last edited by telecastg; 11-26-2022, 08:42 PM.

    Comment


    • #3
      Hello telecastg,
      no, it's not clone a entity like in entityManager, it's more clone a "record".

      for me maybe solution is : https://www.doctrine-project.org/pro...-or-clone.html

      in healthcare, all entity, record, relation must be "isolated" to Patient. (law)
      so sometime, we have same entity, record.. we just need to "clone" one, change some attribute and save. (it's for law :s )

      regards

      Comment


      • telecastg
        telecastg commented
        Editing a comment
        Could you use create a "template" record with just the basic or common to all attributes and links defined and then use the "Duplicate" dropdown option in the detail view to create a clone ?
        Last edited by telecastg; 11-27-2022, 07:04 AM.

    • #4
      Hi telecastg,
      why i have not thinking that



      thanks man

      Comment


      • telecastg
        telecastg commented
        Editing a comment
        My pleasure
    Working...
    X