Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1794

DriverChain unable to load mixed Drivers at given sort of load.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: Mapping Drivers
    • Labels:
      None
    • Environment:
      openSUSE 12.1, Apache 2.2.21

      Description

      From doctrine mailing list http://groups.google.com/group/doctrine-user/browse_thread/thread/86b9a732f3cc1626

      I'm trying to load different mappings methods using DriverChain. My example code is from bug tracker tutorial. I have 3 classes under 'entities' folder: Bug, Product, User that have Annotations and Yaml mapping files, then I've added two more entities under 'entities_1' folder: BugStatus and Client with Annotations and Xml mapping files. 'status' field from Bug table point to BugStatus id, same thing to 'client' field from Client that point to Product. I know is a bad design, is only for test. So you can see, there is a dependency from first three files to last two classes.

      My tests are only using console with: php doctrine orm:info

      1) I can load last two files using Annotations and Xml, so they work as stand alone.

      Annotations-Xml, Xml-Annotations
      2) At run time, first I load three files from 'entities' using Annotations, then load two files from 'entities_1' using Xml and both work. (info appear [OK] in all 5 classes).
      3) At run time, first I load two files from 'entities_1' using Xml, then load three files from 'entities' using Annotations and both work too.

      Annotations-Yaml, Yaml-Annotations
      4) At run time, first I load two files from 'entities_1' using Annotation driver, then load three files from 'entities' using Yaml driver and both work.
      5) At run time, first I load three files from 'entities' using Yaml driver, then load two files from 'entities_1' using Annotation driver and fail with this error:

      ----------
      jago@jagobook:/media/Documentos/Programacion/localhost/doctrine_full/libraries/Doctrine/bin> php doctrine orm:info
      Found 5 mapped entities:
      [OK] Entities\Bug
      [OK] Entities\Product
      [OK] Entities\User
      [FAIL] Entities_1\BugStatus
      No mapping file found named 'Entities_1.BugStatus.dcm.yml' for class 'Entities_1\BugStatus'.

      [FAIL] Entities_1\Client
      No mapping file found named 'Entities_1.Client.dcm.yml' for class 'Entities_1\Client'.

      jago@jagobook:/media/Documentos/Programacion/localhost/doctrine_full/libraries/Doctrine/bin>
      -----------

      Seem that search metadata from Yaml configuration, when they are added to DriverChain using Annotation driver:

      -----------
      //YAML
      require_once '../../../entities/Bug.php';
      require_once '../../../entities/Product.php';
      require_once '../../../entities/User.php';
      $path = '/media/Documentos/Programacion/localhost/doctrine_full/entities/mapping';
      $yaml = new \Doctrine\ORM\Mapping\Driver\YamlDriver( array( $path ) );
      $dc->addDriver( $yaml, "Entities" );

      //Annotations
      $path = '/media/Documentos/Programacion/localhost/doctrine_full/entities_1';
      $an2 = $config->newDefaultAnnotationDriver( $path );
      $dc->addDriver( $an2, "Entities_1" );

      $config->setMetadataDriverImpl( $dc );
      --------------

      Or I miss something?

      Thanks in advance.

      Some screenshots, see in transparent console code from NetBeans
      ------------
      annotations then xml
      http://i.imgur.com/BfIKC.png

      xml then annotations
      http://i.imgur.com/hqsJ0.png

      --------------

      annotations then yaml
      http://i.imgur.com/Linrs.png

      yaml then annotations (error)
      http://i.imgur.com/gctpI.png

        Activity

        Hide
        Benjamin Eberlei added a comment -

        this obviouisly doesnt work, as Entities match Entities_1 already. You have to sort them in reverse order to make it working.

        Show
        Benjamin Eberlei added a comment - this obviouisly doesnt work, as Entities match Entities_1 already. You have to sort them in reverse order to make it working.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            feathers and down
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: