[Fixed] Missing Lifecycle callbacks on Doctrine2 entities import?

0 votes
asked Feb 12, 2015 in Solved by Julien.Verrecchia (180 points)
recategorized Mar 19, 2015 by ludek.vodicka

v3.0.2.1162
While importing existing Doctrine2 entities in Skipper, i noticed that all Lifecycle callbacks were missing.

If they are manually added in Skipper, they are generated in the same way as in the original Doctrine 2 file.

Is it a known issue?

commented Feb 12, 2015 by ludek.vodicka Skipper developer (140,450 points)

Thanks for reporting. We will check it tomorrow and let you know.

1 Answer

0 votes
answered Feb 13, 2015 by ludek.vodicka Skipper developer (140,450 points)

Hi,

I have tested it and it seems that everything works fine. Can you please send us some testing file where you think the import doesn't work?

This is what we have in our unit-test database:

<?php

/** @Entity @HasLifecycleCallbacks */
class User
{
// ...

/**
 * @Column(type="string", length=255)
 */
public $value;

/** @Column(name="created_at", type="string", length=255) */
private $createdAt;

/** @PrePersist */
public function doStuffOnPrePersist()
{
    $this->createdAt = date('Y-m-d H:m:s');
}

/** @PrePersist */
public function doOtherStuffOnPrePersist()
{
    $this->value = 'changed from prePersist callback!';
}

/** @PostPersist */
public function doStuffOnPostPersist()
{
    $this->value = 'changed from postPersist callback!';
}

/** @PostLoad */
public function doStuffOnPostLoad()
{
    $this->value = 'changed from postLoad callback!';
}

/** @PreUpdate */
public function doStuffOnPreUpdate()
{
    $this->value = 'changed from preUpdate callback!';
}
}

And this is imported result:

Skipper Doctrine2 lifecycle callbacks

commented Feb 13, 2015 by Julien.Verrecchia (180 points)

Hi,

In my case I have "@ORM\HasLifecycleCallbacks".
The prefix "@ORM" seems OK for all other attributes but doesn't seem to work for HasLifecycleCallbacks.

For instance, this doesn't import the @PreUpdate callback :

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="TEST")
 * @ORM\HasLifecycleCallbacks
 */

But this works :

use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\HasLifecycleCallbacks as HasLifecycleCallbacks;

/**
 * @ORM\Entity
 * @ORM\Table(name="TEST")
 * @HasLifecycleCallbacks
 */

Thanks

commented Feb 13, 2015 by ludek.vodicka Skipper developer (140,450 points)

Interesting. I will check it.

commented Mar 19, 2015 by ludek.vodicka Skipper developer (140,450 points)

Fixed in latest release

...