Search code examples
phpdoctrinedoctrine-ormphp-5.3collision

Doctrine 2: Proxy name collisions


I'm learning Doctrine 2, and noticed that the name of a generated proxy class is the original class' full name, without the namespace separator, with Proxy appended to it.

What if you use a namespaced domain model, and there is a collision?

Order         => OrderProxy
OrderProduct  => OrderProductProxy
Order\Product => OrderProductProxy (!)

Is it possible to change the naming convention for such proxies?


Solution

  • Looks like it's not possible at the moment.

    The source code shows that this naming convention is hardcoded:

    $proxyClassName = str_replace('\\', '', $className) . 'Proxy';
    

    Anyway, I now tend to think that's it's not such a bad thing: by trying to avoid such collisions, we remove confusion in the naming of our domain classes.