Details
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().
My initial comments:
== UPDATE ==
I just realized that the old alias map implementation completely bypassed the cache (ouch!). You would never get a hit on $this->_loadedMetadata with an alias because the metadata is only stored for the fully qualified class name. As a result the metadata is loaded again and again and again on each invocation, whether its from the metadata cache or from the sources, both is awful.
Summary:
1) The old/current alias map implementation is badly broken.
2) The new implementation is too slow and I dont see an elegant way to do it properly.
When reconsidering that we're talking of a (imho minor) convenience feature here, unless someone has a good implementation for getMetadataFor that is both fast and correct, I dont see a way to support that feature, neither the old one nor the new one.