You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an entity named A, which owns a OneToOne relation with the Document entity of the cookbook (the one that is being uploaded), and with cascade={remove}.
If I delete A, then Doctrine deletes Document, and only after deletion it tries to execute its PostRemove callback. So in this callback you can't access any property of Document. If you do, you face an Entity was not found exception.
This is the same case as in #712 where you can't access the id property.
The same workaround should be used: save the filename in PreRemove, and use it from PostRemove. This code actually works:
/**
* @ORM\PreRemove()
*/
public function preRemoveUpload()
{
// we temporarly save the filename
$this->filename = $this->getUploadRootDir().'/'.$this->getMyFileName();
}
/**
* @ORM\PostRemove()
*/
public function removeUpload()
{
// we use the saved filename
if (file_exists($this->filename)) {
unlink($this->filename);
}
}
The text was updated successfully, but these errors were encountered:
Hi,
I have an entity named A, which owns a OneToOne relation with the Document entity of the cookbook (the one that is being uploaded), and with
cascade={remove}
.If I delete A, then Doctrine deletes Document, and only after deletion it tries to execute its PostRemove callback. So in this callback you can't access any property of Document. If you do, you face an
Entity was not found
exception.This is the same case as in #712 where you can't access the id property.
The same workaround should be used: save the filename in PreRemove, and use it from PostRemove. This code actually works:
The text was updated successfully, but these errors were encountered: