19
I have this method in my entity:
/**
* @ORM\PreUpdate()
* @ORM\PrePersist()
*/
public function preStore() {
if ($this->getPictureFile()) {
$newFilename = sha1(mt_rand());
$newFilename = $newFilename . '.' . ($this->getPictureFile()->guessExtension());
$this->setPictureFilename($newFilename);
}
}
And when persisting objects everything works just perfectly but on update the method is not triggered at all, i tested it this way:
/**
* @ORM\PreUpdate()
* @ORM\PrePersist()
*/
public function preStore() { var_dump('asdasdasdadsdasdas');
if ($this->getPictureFile()) {
$newFilename = sha1(mt_rand());
$newFilename = $newFilename . '.' . ($this->getPictureFile()->guessExtension());
$this->setPictureFilename($newFilename);
}
}
And in persisting var_dump works, but when I update the object - it doesn't. Why?