0 votes

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?

in Solved by (180 points)
recategorized by

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

1 Answer

0 votes

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

by Skipper developer (138k 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

Interesting. I will check it.

Fixed in latest release