Hi there,
I currently am facing an issue I never had in the past.
Here is the process (and the problem) in question.
My Entity "Test" (for the example) is saved,
I check in its "beforeSave" hook something, if "true", I call a method inside the record Service of the entity "TestNumTwo"
This method take the "Test" entity id in its parameters.
Then, I create a "TestNumTwo" new entity and link it to my "Test" entity.
After saving, no error nor warning are thrown BUT the 2 entities aren't linked at all.
The field "test_id" in the DB is empty and my "TestNumTwo" is created without the link.
I tried 2 differents ways to create my "TestNumTwo" entity (in order to check if something different would happen).
First one
The one I tried to do (with no different result)
What did I do wrong and how should I fix it ?
Thanks.
Regards,
Firyo.
I currently am facing an issue I never had in the past.
Here is the process (and the problem) in question.
My Entity "Test" (for the example) is saved,
I check in its "beforeSave" hook something, if "true", I call a method inside the record Service of the entity "TestNumTwo"
This method take the "Test" entity id in its parameters.
Then, I create a "TestNumTwo" new entity and link it to my "Test" entity.
After saving, no error nor warning are thrown BUT the 2 entities aren't linked at all.
The field "test_id" in the DB is empty and my "TestNumTwo" is created without the link.
I tried 2 differents ways to create my "TestNumTwo" entity (in order to check if something different would happen).
First one
PHP Code:
$this->entityManager->createEntity('TestNumTwo', [
'name' => $name,
'description' => $description,
'context' => $context,
'testId' => $entityId, // "Test" entity id here
'createdById' => $createdBy
]);
PHP Code:
$testNumTwo = $this->entityManager
->getRDBRepository('TestNumTwo')
->getNew();
$testNumTwo->set('name', $name);
$testNumTwo->set('description', $description);
$testNumTwo->set('context', $context);
$testNumTwo->set('testId', $entityId);
$testNumTwo->set('createdById', $createdBy);
$this->entityManager->saveEntity($testNumTwo);
What did I do wrong and how should I fix it ?
Thanks.
Regards,
Firyo.
Comment