mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1006: Entity Generator Regenerate If Not New #1252
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jan 31, 2011).
Originally assigned to: @beberlei on GitHub.
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 commented on GitHub (Feb 2, 2011):
Comment created by @beberlei:
blank as in the file is completly empty?
@doctrinebot commented on GitHub (Feb 2, 2011):
Comment created by sw45859:
no, it generates just the class with no properties or methods.
@doctrinebot commented on GitHub (Feb 2, 2011):
Comment created by @beberlei:
Fixed
@doctrinebot commented on GitHub (Feb 2, 2011):
Issue was closed with resolution "Fixed"