Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1006

Entity Generator Regenerate If Not New

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.2, 2.1
    • Component/s: Tools
    • Security Level: All
    • Labels:
      None

      Description

      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)

        Activity

        Hide
        Benjamin Eberlei added a comment -

        blank as in the file is completly empty?

        Show
        Benjamin Eberlei added a comment - blank as in the file is completly empty?
        Hide
        Stephen Walker added a comment -

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

        Show
        Stephen Walker added a comment - no, it generates just the class with no properties or methods.
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Stephen Walker
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: