0

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  {
    // ...
}
Community
  • 1
  • 1
rudak
  • 379
  • 3
  • 16

1 Answers1

0

Can you please add abstract class and the Entities using that mappedsuperclass? It still sounds like it misses some specifications.

SenseException
  • 1,015
  • 12
  • 14
  • edited but i dont think the code will help you more. (The probleme is the same as linked) – rudak Jan 12 '14 at 13:42