0 votes

Mac Osx (Mountain Lion), OrmDesigner2

I created entity "User" with rows: createdat, updatedat and i try to use "lifecycle-callback's" for them.

enter image description here

After export to php files (entity User), he has:

 * @ORM\HasLifecycleCallbacks
 */
class User

  /** 
   * @ORM\Column(type="datetime", nullable=false)
   */
  private $created_at;

  /** 
   * @ORM\Column(type="datetime", nullable=false)
   */
  private $updated_at;

  /** 
   * @ORM\PrePersist
   */
  public function setCreatedAt()
  {
  }

  /** 
   * @ORM\PreUpdate
   */
  public function setUpdatedAt()
  {
  }

As you can see, they without any variables, what i do wrong, or this is bug?

asked Jan 29, 2013 in Feature Request by iniweb (270 points)
recategorized Jan 31, 2013 by ludek.vodicka

I'm not sure what you expect as export result.

ORM Designer correctly generated two methods "setCreatedAt" and "setUpdatedAt" and marked them as PrePersist and PreUpdate. What kind of variables are you missing?

I expect from ORM Designer something like this:

  /** 
   * @ORM\PrePersist
   */
  public function setCreatedAt($created_at)
  {
    $this->created_at = $created_at;
  }

Because doctrine entities generator not do this, if you already wrote this function.

I'm suppose you're mixing two things together. Lifecycle callbacks doesn't have any parameters as you can see in Doctrine2 documentation:

http://docs.doctrine-project.org/en/2.0.x/reference/events.html#lifecycle-callbacks

What you probably want are setters and getters. Unfortunately ORM Designer doesn't support export of setters/getters right now, but you can configure External Tools to generate getters and setters in one click.

1 Answer

0 votes
Best answer

It is possible two things maybe mixed together in this request.

Lifecycle callbacks don't have any parameters as you can see in Doctrine2 documentation:

http://docs.doctrine-project.org/en/2.0.x/reference/events.html#lifecycle-callbacks

What you probably want are setters and getters. Unfortunately ORM Designer doesn't support export of setters/getters right now, but you can configure External Tools to generate getters and setters in one click.

answered Jul 30, 2014 by Martin Freki Stradej Skipper developer (74,870 points)