简体   繁体   English

教义2-产生实体

[英]doctrine2 - generating entities

i'm using doctrine2 cli for generating entities. 我正在使用doctrine2 cli生成实体。

i have the original classes defined in PHP with docblock. 我有用docblock在PHP中定义的原始类。 when i run the doctrine orm:generate-entities, the new files are created - fields are generate, and methods (setters/getters) are created. 当我运行主义orm:generate-entities时,将创建新文件-生成字段,并创建方法(设置器/获取器)。

the problem is, i want to copy my own custom methods from the original files (without extending the files). 问题是,我想从原始文件复制我自己的自定义方法(不扩展文件)。

for example: i have skel\\Employee.php with: 例如:我有skel \\ Employee.php与:

class Employee {
    /** comments */
    public $key;
    public function myCustomMethod(){
        ....
    }
}

when i run orm:generate-entites, models\\Employee.php is created but myCustomMethod() is not copied 当我运行orm:generate-entites时,创建了models \\ Employee.php但未复制myCustomMethod()

is there a way to copy custom commands? 有没有办法复制的自定义命令?

Create your models / entities in code first with annotation mapping then use orm:schema-tool:create to create your database schema and if not doing so automatically, orm:generate-proxies . 首先使用注释映射在代码中创建模型/实体,然后使用orm:schema-tool:create创建数据库模式;如果没有自动创建,则使用orm:generate-proxies

See the note here 看到这里的笔记

If you are however putting much more logic on the entities you should refrain from using the entity-generator and code your entities manually. 但是,如果要对实体施加更多的逻辑,则应避免使用实体生成器并手动编码实体。

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

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