Page 1 of 1

Module Development 1.9.x and 1.10 differences

Posted: Tue Nov 08, 2011 10:10 am
by Dabnis
Hi All,
I have searched the forum, asked via #irc etc for an answer to this question, but without success.
This is my situation:
I recently bought the CMSMS Dev Cookbook and was working my way through the book when 1.10 was released. As it is common practice to design for the future I started to apply the tutorial code from the book within a 1.10 environment. Could not even get the basic 'HelloWorld' module to install.
Since the above I have been searching for information regarding the differences between 1.9.x and 1.10 from a module development perspective, but without success.
Any help / advice would be appreciated.
Thanks

Re: Module Development 1.9.x and 1.10 differences

Posted: Tue Nov 08, 2011 3:04 pm
by mcDavid
I think the official announcement covers the most of it:

http://www.cmsmadesimple.org/2011/10/An ... +Simple%29
What We Broke (Technical Stuff):

1: Removing $gCms→smarty, use cmsms()→GetSmarty() instead.
In older versions of CMSMS the $gCms object contained a reference to the global smarty object. The global smarty object is now a singleton to ensure that it cannot be instantiated more than once.

2: Removed the $gCms→config, use cmsms()→GetConfig() instead.
Similar to the Smarty object, the config object is also a singleton. Therefore that method of accessing the config object has been removed.

3: Removed the $gCms→modules array. use cms_utils::get_module() instead.
The public modules array, a throwback to the days of php4 has been removed, and replaced with a complete api (see the ModuleOperations class). A simple method to obtain a module object reference has been (since CMSMS 1.9) the cms_utils::get_module() method. This may effect your UDT’s the most.

4: Revised the content objects
In CMSMS 1.10, as the first step in revising our object interface for the sake of efficiency we have revised the Content object to ensure that all member variables are private and that accessors exist for each data member. The most prominent of these is the ‘mModifiedDate’ member of the content object, which was public but had no accessor method.

5: The CmsObject class is now final and a singleton.
In CMSMS 1.10, the CmsObject class (aka the $gCms variable) is now a final, non-extendable class.

6: Removed deprecated callbacks from the module api.
The last of the long deprecated callbacks were removed from the module class as they have been replaced by events for a long time.

7: Private, Protected, and final methods in the module API.
Our first step in the cleanup of the module API was to clean up the interfaces for this class. We have declared most methods to be public or protected. Some methods are also final and cannot be overridden. We have also deprecated the Redirect methods of the module API.

8: Replaced, but deprecated some members of the module class.
The smarty, db, and config members of the module class (which were references to the global versions of those objects) have been removed, and replaced with access methods. Though this should not break compatibility the following is now deprecated:

$this→smarty – when $smarty is not provided to you in scope, you should use cmsms()→GetSmarty()
$this→db – when $db not provided to you in scope, you should use cmsms()→GetDb();
$this→config – you should use cmsms()→GetConfig();
$this→cms – When not provided in scope, you should use $gCms = cmsms();

Re: Module Development 1.9.x and 1.10 differences

Posted: Tue Nov 08, 2011 3:36 pm
by Dabnis
Yes I had already read the above, but this does not solve my problem of why the basic HelloWorld demo within the CMSMS Dev Cookbook code just does not work and uses none of the global (now singleton) objects that are mentioned.
Thanks for the reply though.