Closed mdjaman closed 3 years ago
Please provide a unit test to describe what you're talking about.
Maybe it is linked with the hydrator
update.json [ { "created_at": "2019-02-14T09:57:56-0500", "updated_at": "2020-05-20T11:40:27-0400", "id": "5c6581f45771db0320faf769", "name": "Fiche A", "code": "FNC", "alias": "fiche-a", "description": "Fiche de notification a", "disease": { "id": "5b06a66d5771dba3c7a6a598" }, "template": false, "complete": true, "useAsDefault": false, "items": [ { "created_at": "2019-02-14T09:57:56-0500", "updated_at": "2020-05-27T13:40:27-0400", "id": "5c6581f45771db0320faf76b", "label": "Identifiant Unique", "name": "EPID", "alias": "epid_1", "type": "", "required": false, "readonly": false, "values": [], "position": 1, "tag": "epid", "children": [ { "created_at": "2019-02-14T09:57:56-0500", "updated_at": "2020-05-21T15:05:23-0400", "id": "5c6581f45771db0320faf777", "label": "Code échantillon", "name": "code", "alias": "code_1", "type": "text", "required": false, "readonly": false, "values": [], "position": 1, "children": [], "masks": [], "validators": [] } ], "meta": { "locked": true, "cascadeOperation": false }, "masks": [], "validators": [] } ], "dataTable": { "created_at": "2020-05-27T13:56:38-0400", "id": "5ecea9d6a47e486913436400", "name": "Tableau de données A", "alias": "tableau-de-donnees-a", "columns": [] }, "meta": { "finalResultField": "finalresult" } }]
NotificationFormItem.php (Details/Child)
class NotificationFormItem {
/**
* @var string
* @ODM\Id
*/
protected $id;
/**
* @var string
* @ODM\Field(type="string")
*/
protected $label;
/**
* @var string
* @ODM\Field(type="string")
*/
protected $name;
/**
* @var string
* @ODM\Field(type="string")
*/
protected $alias;
/**
* @var string
* @ODM\Field(type="string")
*/
protected $description;
/**
@ODM\Field(type="collection") */ protected $values = [];
/**
@ODM\ReferenceOne(targetDocument="NotificationForm", inversedBy="items", storeAs="id") */ protected $notificationForm;
/**
) */ protected $parent;
/**
) */ protected $children;
/**
// skipping getters/setters NotificationForm.php (Master/Parent)
class NotificationForm extends BaseDocument { use BlameableDocument;
/**
* @var string
* @ODM\Id
*/
protected $id;
/**
* @var string
* @ODM\Field(type="string")
*/
protected $name;
/**
* @var string
* @ODM\Field(type="string")
*/
protected $code;
/**
* @var string
* @ODM\Field(type="string")
*/
protected $alias;
/**
* @var string
* @ODM\Field(type="string")
*/
protected $description;
/**
* @var Collection|array
* @ODM\ReferenceMany(
* targetDocument="NotificationFormItem",
* mappedBy="notificationForm",
* storeAs="id",
* sort={"position": "asc"},
* cascade={"all"}
* )
*/
protected $items;
/**
* NotificationForm constructor.
*/
public function __construct()
{
$this->items = new ArrayCollection();
}
What i doing is hydrate new entity from the json array
Conversation moved to duplicate issue: https://github.com/doctrine/DoctrineModule/issues/708
Hello maybe i am totally wrong but persisting master and details (one to many) reset generate new id of children even if i gave it my own id