-
☆ A M B ☆
- 165 Posts
Hello;
Can i get some advice on naming conventions for custom classes and aliases?
I was working on a CMP and used the name 'List' for a custom class in the schema and had troubles calling getCollection, getObject but MODx shows nothing on the console, only the output of my snippet is empty. The problem was solved when used another name. I've read somewhere is a good advice to name custom classes with some initials in front like the mayority of MODx's Extras but i can't find it now.
Is there a way to get a warning, debug message in case of class name collisions?
Any help is appreciated.
-
☆ A M B ☆
- 2,475 Posts
This may have more to do with your environment's PHP settings (specifically whether or not you are logging or displaying errors). I suspect the name "List" caused problems because that's the name of a PHP language construct.
Typically, it's common to prefix your class names with something to guarantee their uniqueness (e.g. "My_List"), usually this stems from your package namespace. xPDO allows you to specify a prefix at runtime (when creating database tables) so you could still use simple names in your schema.
Seems like it'd be good to have a set of naming conventions/requirements posted in the docs somewhere...
-
☆ A M B ☆
- 165 Posts
Thanks a lot.
Was building a CMP and error reporting is Off as default in the MODx Cloud. A little tricky to know what's happening for xpdo non-experts. Specially in this case where the error.log is located outside the public files in /log/error.log
The collision problem wasn't obvious to me at the time as every other Class was working ok. It's a good idea to have this in the docs as suggestions.
Thanks for the help.
[ed. note: lithiumlab last edited this post 13 years, 4 months ago.]