Bridging classes for the new MVC in the CMS

142 views
Skip to first unread message

Andrew Eddie

unread,
May 13, 2012, 6:32:27 PM5/13/12
to joomla-...@googlegroups.com
Cross-posting from the platform list:

I think there's a better way to approach this looking at the practical
side of how the CMS can use the new classes without the use of interfaces.


It seems to me the simplest approach is to copy non-interface versions
of JControllerBase, JModelBase, JModelDatabase, JViewBase and
JViewHtml to the legacy tree.  The reality is those are the classes
that will be used in 4.0 so there's no conflict in dropping them into
3.0.  The following is an outline of how I would see these being used
in the CMS:

CONTROLLERS

JControllerBase is a single task controller. New controllers in 3.0
can be extended from JControllerBase or a multi-task controller that
emulates the old JController can be added to either the platform's
legacy tree or the CMS.  I'll call this JControllerMulti for now.

The CMS needs to look at the derived controllers, like
JControllerForm, and make sure they are future proof (taking out any
deprecated API).

Instructions to developers would be:

a) Strip out deprecated functionality from your controllers and usage
(things like addModelPath, etc).
b) Note that JControllerBase does not extend JObject
c) Convert your existing controllers to extend JControllerMulti, not
JController.
d) Create new single-task controllers from JController Base.
e) Use autoloader rules to help Joomla find your extension's
controllers (maybe the CMS can do this transparently).

Your controllers are now ready for Joomla 4.0.

MODELS

All Joomla extensions would convert to using JModelDatabase eventually
and basically this is an exercise of stripping down the model classes.

Instructions to developers would be:

a) Strip out any deprecated API that is not found in JModelDatabase
(all the include path, etc).
b) Note that JModelDatabase does not extend JObject
c) Convert your existing models to extend JModelDatabase.
d) Use autoloader rules to help Joomla find your extension's models
(maybe the CMS can do this transparently).

Your models are now ready for Joomla 4.0.

VIEWS

You might be lucky, but I think JViewHtml will likely need extended to
provide all of the useful features in the old JView, so you are going
to need a JViewPage/JViewCms or similar (the CMS can haggle over what
name it needs to be).  The main thing is setting up default paths for
the layout overrides.

Instructions to developers would be (like before):

a) Remove deprecated functionality from your views and code
(assignRef, adding paths, etc).
b) Note that JViewBase does not extend JObject
c) Convert your existing views to extend JViewPage/Cms/?
d) Use autoloader rules to help Joomla find your extension's view
classes (maybe the CMS can do this transparently).

Your models are now ready for Joomla 4.0.

----

To me, that would be a sane approach which will use the final products
when the old MVC is dropped.

The only disadvantage with this system is that the CMS is type hinting
at the CMS level - JModel and JModelBase won't be compatible - but a
developer will be able to type hint within the confirms of their own
extension.

Within the pull, the only thing I'm not sure about is the application injected into the controller (in terms of type hinting) but the CMS can work out the best way to deal with that.

Does that all make sense?


Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla developers

Beat

unread,
May 14, 2012, 7:31:00 AM5/14/12
to Joomla! CMS Development
One quick question: has "forward compatibility" also been looked at ?

E.g. for new components it would be good that they can be developed
for Joomla 3.0, but also be made running not to difficultly on Joomla
2.5, as that's a LTS release. So maybe that "forward compatibility"
classes for Joomla 2.5 would help too.

Maybe it's not so important anyway, as such dramatic changes between
Joomla versions do give to large extensions developers a clear signal:
Do not rely on a changing library without an adaptation layer to avoid
having to do to much changes (many such articles describing that
approach exist already).

Andrew Eddie

unread,
May 14, 2012, 5:43:42 PM5/14/12
to joomla-...@googlegroups.com
I don't see any reason why the new classes couldn't be added in 2.x.
Obviously they will restrict you to PHP 5.2 or maybe 5.3 but it could
be done. But it's not like you have to make the change immediately
(just sometime in the next 18 months).

Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla developers


> --
> You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
> To post to this group, send an email to joomla-...@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-cm...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
>

Rouven Weßling

unread,
May 17, 2012, 1:03:25 PM5/17/12
to joomla-...@googlegroups.com
Hmm, I'd rather have the CMS fork (or adopt if we remove them from the platform) the old classes than having to keep our own little forks of the new classes in sync with the platform.

Rouven

--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-cms/-/x9DoFMaKcC0J.
Reply all
Reply to author
Forward
0 new messages