contao/core — pull request #4377 by Toflar (2012-05-24 07:45:19+00:00)
Title: Initial draft and probably working basis to make models extendable

Heads up Contao developers ;-)

At the conference I asked Leo what we do about making models extendable and I couldn't talk to him anymore about this topic because he suddenly disappeared :-D

Anyway. During the conference I started off with a mockup which I finished today.

Seems like the whole autoloading and namespacing doesn't quite work like expected or I just don't get it.
That's why I'm pushing my results on github now so we can publicly work on this matter and discuss about it.
Feel free to fork, test and modify my fork :-)

What have I done so far?

* I have extended the DcaExtractor so it can generate models. It essentially goes over every module in system/modules and checks for model classes in "models" (which would then become mandatory). It takes all the models in reverse order (so overriding is possible) and creates a combined class in system/cache/models. This routine might be useful for you, Leo, no matter if this pull request will find its way into the core or not :-)
* I have created a "test" module where I extended the "PageModel" by some useless method and property to test the new DcaExtractor. This seems to be working like a charm. If everything works fine, this module can be removed.
* I changed the ClassLoader for testing purposes so that models are loaded from the cache automatically. I'm sure there are better options you can come up with!

Problems

* Somehow I ran into namespacing problems so I had to use "class_alias" again in my ClassLoader modifications. Seems like something with the global namespace gets confused but I haven't found the reason for that yet -> your turn! :-)

Let's see if we can get that thing to work as a team :-)