In Joomla when we develop an extension we make some class that extends another class like JModule or JPlugin and we have to use the naming convention for name it for example when we make a plugin we have to use the plg as a naming conventions for class name I am confused how this class work without make any instance of it ?
I assume you mean that you use the class PlgContentMyClass
but then don't have to call it like so:
$foo = new PlgContentMyClass;
It because Joomla follows the observer pattern, which basically means that all subclasses (in this case PlgContentMyClass
) of JPlugin
will automatically register themselves to the JEventDispatcher
class (which is global).
Therefore, they're automatically instantiated and you don't need to do it yourself
Plugin Classes are instantiated "automagically" - at the moment when Joomla triggers a Plugin Event. Depending on the Plugin event that is thrown, the respective plugin classes will get instantiated into objects and all the methods of that event name will be executed.
Joomla plugin events are triggered through the JEventDispatcher
Class that implements the observer design pattern, where events are observable and the plugins are observers.
-
-
1@hhgh4269 - The class for a module is
JModuleHelper
which is also autoloaded. – Lodder Jul 17 '17 at 15:45