CMSPlugin
Implements DispatcherAwareInterface, PluginInterface, LanguageAwareInterfacePlugin Class
since |
1.5 |
---|---|
package |
Joomla CMS |
Methods
__construct
Constructor
__construct(\Joomla\Event\DispatcherInterface &subject, mixed||string|int config = []) :
since |
1.5 |
---|
Arguments
- subject
DispatcherInterface
The object to observe- config
array<string|int, mixed>
An optional associative array of configuration settings. Recognized key values include 'name', 'group', 'params', 'language' (this list is not meant to be comprehensive).
Response
mixed
getApplication
Returns the internal application or null when not set.
getApplication() : \Joomla\CMS\Application\CMSApplicationInterface|null
getLanguage
Get the Language.
getLanguage() : \Joomla\CMS\Language\Language
since |
4.4.0 |
---|---|
throws |
|
Response
loadLanguage
Loads the plugin language file
loadLanguage( extension = '', basePath = JPATH_ADMINISTRATOR) :
since |
1.5 |
---|
Arguments
- extension
string
The extension for which a language file should be loaded- basePath
string
The basepath to use
Response
bool
True, if the file has successfully loaded.
parameterImplementsEventInterface
Checks if parameter is typehinted to accept \Joomla\Event\EventInterface.
parameterImplementsEventInterface(\ReflectionParameter parameter) :
since |
4.0.0 |
---|
Arguments
- parameter
ReflectionParameter
Response
bool
registerLegacyListener
Registers a legacy event listener, i.e. a method which accepts individual arguments instead of an AbstractEvent in its arguments. This provides backwards compatibility to Joomla! 3.x-style plugins.
registerLegacyListener( methodName) :
This method will register lambda functions (closures) which try to unwrap the arguments of the dispatched Event into old style method arguments and call your on<Something> method with them. The result will be passed back to the Event, as an element into an array argument called 'result'.
since |
4.0.0 |
---|
Arguments
- methodName
string
The method name to register
Response
void
registerListener
Registers a proper event listener, i.e. a method which accepts an AbstractEvent as its sole argument. This is the preferred way to implement plugins in Joomla! 4.x and will be the only possible method with Joomla! 5.x onwards.
registerListener( methodName) :
since |
4.0.0 |
---|
Arguments
- methodName
string
The method name to register
Response
void
registerListeners
Registers legacy Listeners to the Dispatcher, emulating how plugins worked under Joomla! 3.x and below.
registerListeners() :
By default, this method will look for all public methods whose name starts with "on". It will register lambda functions (closures) which try to unwrap the arguments of the dispatched Event into method call arguments and call your on<Something> method. The result will be passed back to the Event into its 'result' argument.
This method additionally supports Joomla\Event\SubscriberInterface and plugins implementing this will be registered to the dispatcher as a subscriber.
since |
4.0.0 |
---|
Response
void
setApplication
Sets the application to use.
setApplication(\Joomla\CMS\Application\CMSApplicationInterface application) :
setLanguage
Set the language to use.
setLanguage(\Joomla\CMS\Language\Language language) :
Properties
params
A Registry object holding the parameters for the plugin
since |
1.5 |
---|
Type(s)
Registry
_name
The name of the plugin
since |
1.5 |
---|
Type(s)
string
_type
The plugin type
since |
1.5 |
---|
Type(s)
string
autoloadLanguage
Affects constructor behavior. If true, language files will be loaded automatically.
since |
3.1 |
---|
Type(s)
bool
allowLegacyListeners
Should I try to detect and register legacy event listeners, i.e. methods which accept unwrapped arguments? While this maintains a great degree of backwards compatibility to Joomla! 3.x-style plugins it is much slower. You are advised to implement your plugins using proper Listeners, methods accepting an AbstractEvent as their sole parameter, for best performance. Also bear in mind that Joomla! 5.x onwards will only allow proper listeners, removing support for legacy Listeners.
since |
4.0.0 |
---|---|
deprecated |
4.3 will be removed in 6.0 Implement your plugin methods accepting an AbstractEvent object Example: onEventTriggerName(AbstractEvent $event) { $context = $event->getArgument(...); } |
Type(s)
bool