Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-384

Add support for Entity namespacing globally

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-BETA1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Recently Jonathan committed a patch to support Entity aliasing.
      Patch at first glance looks good, but it has some issues (it double processes the loadedMetadata).

      I have fixed this issue by including a new level of configuration. Instead of create a 1 alias => 1 entity hashmap, I added support for namespacing.
      The idea is similar to AnnotationReader support recently introduced.

      To take advantage of it, simply include the $ormConfig->addEntityNamespace('CMS', 'Doctrine\Tests\ORM\Models');
      Then, just do: "SELECT u FROM CMS:CmsUser u"

      This is also supported in $em->getReference(), ->getRepository(), etc.

      Patch is attached including updated unit test plus another test for getRepository().

        Activity

        Hide
        Guilherme Blanco added a comment -

        Increased priority... this should be fixed ASAP.

        Show
        Guilherme Blanco added a comment - Increased priority... this should be fixed ASAP.
        Hide
        Joshua Nye added a comment - - edited

        I was using the new namespace syntax while trying to get a reference. I'm not sure if support for this was meant or not.

        $config->setAutoGenerateProxyClasses(true); // Enable proxy class generation.
        $config->addEntityNamespace('app', 'app\models'); // Setup namespace on the EntityManager configuration.
        $em = EntityManager::create($conn, $config);
        $user = $em->getReference('app:User', 3610); // Get reference. Triggers generation of invalid PHP proxy class.

        Show
        Joshua Nye added a comment - - edited I was using the new namespace syntax while trying to get a reference. I'm not sure if support for this was meant or not. $config->setAutoGenerateProxyClasses(true); // Enable proxy class generation. $config->addEntityNamespace('app', 'app\models'); // Setup namespace on the EntityManager configuration. $em = EntityManager::create($conn, $config); $user = $em->getReference('app:User', 3610); // Get reference. Triggers generation of invalid PHP proxy class.
        Hide
        Roman S. Borschel added a comment -

        This should be fixed now. Can you confirm?

        Show
        Roman S. Borschel added a comment - This should be fixed now. Can you confirm?
        Hide
        Joshua Nye added a comment -

        Yes, it's working again. Thanks.

        Show
        Joshua Nye added a comment - Yes, it's working again. Thanks.
        Hide
        Roman S. Borschel added a comment -

        Seems to be ok now.

        Show
        Roman S. Borschel added a comment - Seems to be ok now.

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Guilherme Blanco
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: