Skip to content

Loading…

DDC-1006: Entity Generator Regenerate If Not New #1591

Closed
doctrinebot opened this Issue · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user sw45859:

When regenerating entities from xml ( and i am sure all others ) it gives a blank entity class when the file exists and the regenerateIfExists is set to true, the expected result would be a full entity with any removed columns removed from the entity and new columns to be added.

i've come up with a fix that i assume is the correct way
i haven't tested this without the regeneration set to true since my application requires the regeneration, here's my code block i'm using:

$em->getConfiguration()->setMetadataDriverImpl(
new \Doctrine\ORM\Mapping\Driver\SesXmlDriver(
'ext/Doctrine/Entities/xml_metadata/'
)
);

$cmf = new Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
$cmf->setEntityManager($em);
$metadata = $cmf->getAllMetadata();

$generator = new \Doctrine\ORM\Tools\EntityGenerator();
$generator->setGenerateAnnotations(true);
$generator->setGenerateStubMethods(true);
$generator->setRegenerateEntityIfExists(true);
//$generator->setUpdateEntityIfExists(true);
$generator->generate($metadata, 'ext/');

in the *hasProperty and *hasMethod functions, need to add the below to the inline check:

|| ( ! $this->isNew && $this->regenerateEntityIfExists)

@doctrinebot

Comment created by @beberlei:

blank as in the file is completly empty?

@doctrinebot

Comment created by sw45859:

no, it generates just the class with no properties or methods.

@doctrinebot

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0.2 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.