@HasLifecycleCallbacks @PrePersist @PreUpdate

187 views
Skip to first unread message

Rodrigue Moulin

unread,
Jan 13, 2012, 6:26:31 AM1/13/12
to flextrine
Hello

Is there is a way in flextrine to manage entities "dateInserted" and
"dateCreated" like in doctrine using the @PreUpdate metadata for
example.

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

/** @Column(type="datetime") */
private $dateInserted;

/** @Column(type="datetime") */
private $dateUpdated;

public function __construct()
{
$this->$dateInserted = new \DateTime("now");
}

/** @PreUpdate */
public function doStuffOnPreUpdate()
{
$this->dateUpdated = new \DateTime("now");
}
}

Thanks

Dave Keen

unread,
Jan 13, 2012, 1:28:02 PM1/13/12
to flex...@googlegroups.com
Hey Rodrigue,

Yes - exactly this should work fine. You can also use the @PreConstruct
event to set a date when an entity is created.

Dave

> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2012.0.1901 / Virus Database: 2109/4739 - Release Date: 01/12/12
>
>

Rodrigue Moulin

unread,
Jan 16, 2012, 10:32:30 AM1/16/12
to flextrine
Thanks for your help. But @PreConstruct doesn't seem to work.
@PrePersist and @PreUpdate work fine.

Rod

Dave Keen

unread,
Jan 17, 2012, 3:49:23 AM1/17/12
to flex...@googlegroups.com, Rodrigue Moulin
Oop - I meant to say @PrePersist, not @PreConstruct.

Too much Robotlegs ;)

Dave

> Version: 2012.0.1901 / Virus Database: 2109/4745 - Release Date: 01/15/12
>
>
>

Reply all
Reply to author
Forward
0 new messages