I use a class that extend an abstract class containing lifecyclecallbacks. My abstract class is annotated with @ORM\MappedSuperclass but my callbacks are not triggered. I saw a lot of problems here and there on this subject but no concrete answers. Has anyone have a solution that really works? (I specify that if I call my callback methods manually everything works perfectly)
The answer on this link dont work for me :
Doctrine 2 LifecycleCallbacks with abstract base class are not called
(but the problem is the same)
<?php
// ...
/**
* @ORM\MappedSuperclass
* @ORM\HasLifecycleCallbacks
*/
abstract class Picture {
// ...
/**
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function preUpload() {
echo 'preUpload ';
if (null !== $this->getFile()) {
$this->picture = $this->getNewFilename(10);
}
}
}
/**
* User
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="Myown\UserBundle\Entity\UserRepository")
*/
class User extends Picture {
// ...
}
Can you please add abstract class and the Entities using that mappedsuperclass? It still sounds like it misses some specifications.