简体   繁体   English

如何更改实体类名称Doctrine生成

[英]How to change entity class names Doctrine generated

I'm using Doctrine 2 and use these functions to generate entities from existing DB: 我正在使用Doctrine 2并使用这些函数从现有DB生成实体:

    $cmf = new DisconnectedClassMetadataFactory();
    $cmf->setEntityManager($this->em);
    $metadata = $cmf->getAllMetadata();
    $generator = new EntityGenerator();

    $generator->setUpdateEntityIfExists(true);
    $generator->setGenerateStubMethods(true);
    $generator->setGenerateAnnotations(true);
    $generator->generate($metadata, APPPATH."models/entities");

but i want to change names of entity class just like these: "ActionsEntity", "UserEntity". 但我想改变实体类的名称,如下所示:“ActionsEntity”,“UserEntity”。 Not want "Actions" and "User" etc. 不想要“动作”和“用户”等。

Go to ORM/Tools/EntityGenerator.php Line 347 转到ORM / Tools / EntityGenerator.php第347行

private function _generateEntityClassName(ClassMetadataInfo $metadata)

apply changes you want in this function. 在此功能中应用您想要的更改。

Go to Line 584 转到第584行

private function _generateEntityStubMethods(ClassMetadataInfo $metadata)

apply changes you want in this function. 在此功能中应用您想要的更改。

Go to Line 766 转到766行

private function _generateAssociationMappingPropertyDocBlock

apply changes you want in this function. 在此功能中应用您想要的更改。

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

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