-
Book Overview & Buying
-
Table Of Contents
Mastering Joomla! 1.5 Extension and Framework Development Second Edition
Many of the core classes in Joomla! use a special method called getInstance(). There are three main reasons for using the getInstance() method:
It makes it easier to keep track of objects. Take the JDatabase object as an example. We can access this object at any time using the static JFactory::getDBO() method. If we were unable to do this, we would need to continually pass the object around or declare it global in every method and function that required it.
It helps prevent us from duplicating work. For classes that support it, we do not have to continually instantiate a new object of that type every time we need it. This helps reduce the overall work that PHP is required to complete.
It provides us with a common way of instantiating globally available objects that conform to standards within the Joomla! core.
There are various ways to use this method; we will start by looking at using it to implement the singleton pattern.
We restrict the instantiation...
Change the font size
Change margin width
Change background colour