简体   繁体   English

Doctrine2。 产生生命周期

[英]Doctrine2. Generating lifecycles

Im using YAML for decription entity metadata. 我正在使用YAML解密实体元数据。 Like this: 像这样:

lifecycleCallbacks:
    prePersist: [ doSome ]
    preUpdate: [ doSome ]

Generated entity class looks like this: 生成的实体类如下所示:

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

It is all works fine, but this annotation "@ORM" confusing me. 一切正常,但是这个注解“ @ORM”使我感到困惑。 Should not be like this: 不应该是这样的:

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

How do i get rid of @ORM annotations? 我如何摆脱@ORM注释?

Metafile named as table.orm.yml. 图元文件名为table.orm.yml。 May be this cause the problem? 这可能是造成问题的原因吗? But i dont know, how do this another way. 但我不知道,这是另一种方式。 If i name file like table.dcm.yml, i have exception that metadata not found. 如果我命名为table.dcm.yml之类的文件,则存在未找到元数据的异常。

You can safely remove the annotation and the corresponding use statement after the class has been generated. 生成类后,可以安全地删除注释和相应的use语句。

The command ... 命令 ...

app/console doctrine:generate:entities

... is just a little helper to create classes and/or getter/setter methods. ...只是创建类和/或getter / setter方法的小帮手。

It isn't always 100% accurate. 它并不总是100%准确。 You shouldn't bother about that too much. 您不应该为此烦恼太多。 It's just a helper ... 它只是一个帮手...

You'll still need to write your callback functions yourself anyway. 无论如何,您仍然需要自己编写回调函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM