Building classes that do not relate specifically to part of the Joomla! framework is
a common way to extend Joomla! beyond its intended scope. We discussed in a
previous chapter the use of plugins in lieu of library extensions. If we want, we can
use the same logic, JLoader, to create 'internal' libraries in any extension.
Making extensions easy to build is all part of the logic behind helper classes. These
static classes allow us to categorize functionality and increase the code reuse.
Programming patterns are one of the weapons we can use to tackle a problem.
Joomla! uses patterns extensively, from the complex MVC to basic iterators. A
common pattern found in Joomla! is the use of the getInstance() method.
Whenever we have objects that we want to make globally available we should
consider implementing a getInstance() method in the corresponding class. You
can also consider creating a class similar to the core class JFactory to further increase
accessibility of global objects.
A JRegistry object handles the site settings and extension settings, stored in INI,
XML, and PHP files.
Pages:
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268