Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Namespaces and classmap

propel
Discussion topic

Back to topic list

Namespaces and classmap

Reply

Author tony_bibbs
Full name Tony Bibbs
Date 2008-09-08 10:40:23 PDT
Message I'm working through adding namespace support and when running my tests I now get this error:

Fatal error: Class 'bookstore::Map::Acc​tAccessRoleMapBuilde​r' not found in /home/tony/public_ht​ml/Propel/trunk/gene​rator/projects/books​tore/build/classes/b​ookstore/om/BaseAcct​AccessRolePeer.php on line 88. That particular line of code is:

self::$mapBuilder = new bookstore::Map::Acct​AccessRoleMapBuilder​();

That line fails because the autoload which uses the classmap currently knows nothing about namespaces which is what I want to fix. I need to modify the convert-props task to use the fully qualified when building the classmap. The problem I have is how to best do this without breaking a bunch of existing code. The options are:

1) Modify DataModelBuilder.php (which I assume is the abtract parent of all builders). In that class there is a method called prefixClassname. All it does is append a prefix to the class name. Regardless if this is the right place, I would assume the old "class.prefix" setting will be deprecated. If so you could argue I should just add a new method called namespaceClassname() and leave prefixClassname() so it too can be deprecated.

2) Modify PropelConvertConf.php where it is actually building the mapping file and have all class names listed there to use the full namespace qualifier in front of it. So instead of this:

'BookMapBuilder' => 'bookstore/map/BookM​apBuilder.php',

You'd have something like:

'bookstore::Map::Boo​kMapBuilder' => 'bookstore/map/BookM​apBuilder.php',

It should be noted that I have taken great care to allow the use of namespaces to be turned off. If it is turned of it all still works the way it does today which may be the best reason for not deprecating the stuff I mentioned until 5.3 is set as the minimum version required by Propel.

I'd like to hear which of my two option above make the most sense OR some other alternative you may know of.

Thanks in advance,
 
--Tony

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

Namespaces and classmap tony_bibbs Tony Bibbs 2008-09-08 10:40:23 PDT
Messages per page: