简体   繁体   中英

How to change entity class names Doctrine generated

I'm using Doctrine 2 and use these functions to generate entities from existing 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". Not want "Actions" and "User" etc.

Go to ORM/Tools/EntityGenerator.php Line 347

private function _generateEntityClassName(ClassMetadataInfo $metadata)

apply changes you want in this function.

Go to Line 584

private function _generateEntityStubMethods(ClassMetadataInfo $metadata)

apply changes you want in this function.

Go to Line 766

private function _generateAssociationMappingPropertyDocBlock

apply changes you want in this function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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