AbstractEvent
Extends \Joomla\Event\EventThis class implements the base Event object used system-wide to offer orthogonality. Core objects such as Models, Controllers, etc create such events on-the-fly and dispatch them through the application's Dispatcher (colloquially known as the "Joomla! plugin system"). This way a suitable plugin, typically a "system" plugin, can modify the behaviour of any internal class, providing system-wide services such as tags, content versioning, comments or even low-level services such as the implementation of created/modified/locked behaviours, record hit counter etc.
You can create a new Event with something like this:
$event = AbstractEvent::create('onModelBeforeSomething', $myModel, $arguments);
You can access the subject object from your event Listener using $event['subject']. It is up to your listener to determine whether it should apply its functionality against the subject.
This AbstractEvent class implements a mutable event which is allowed to change its arguments at runtime. This is generally unadvisable. It's best to use AbstractImmutableEvent instead and constrict all your interaction to the subject class.
since |
4.0.0 |
---|---|
package |
Joomla CMS |
Methods
__construct
Constructor. Overridden to go through the argument setters.
__construct(string name, array arguments = []) : mixed
since |
4.0.0 |
---|
Arguments
- name
string
The event name.- arguments
array
The event arguments.
Response
mixed
create
Creates a new CMS event object for a given event name and subject. The following arguments must be given: subject object The subject of the event. This is the core object you are going to manipulate.
create(string eventName, array arguments = []) : static
eventClass string The Event class name. If you do not provide it Joomla\CMS\Events<eventNameWithoutOnPrefix> will be used.
since |
4.0.0 |
---|---|
throws |
|
Arguments
- eventName
string
The name of the event, e.g. onTableBeforeLoad- arguments
array
Additional arguments to pass to the event
Response
static
getArgument
Get an event argument value. It will use a getter method if one exists. The getters have the signature:
getArgument(string name, mixed default = null) : mixed
get<ArgumentName>($value): mixed
where:
$value is the value currently stored in the $arguments array of the event It returns the value to return to the caller.
since |
4.0.0 |
---|
Arguments
- name
string
The argument name.- default
mixed
The default value if not found.
Response
mixed
The argument value or the default value.
getEventClassByEventName
Get the concrete event class name for the given event name.
getEventClassByEventName(string eventName) : string
This method falls back to the generic Joomla\Event\Event class if the event name is unknown to this trait.
since |
4.2.0 |
---|
Arguments
- eventName
string
The event name
Response
string
The event class name
setArgument
Add argument to event. It will use a setter method if one exists. The setters have the signature:
setArgument(string name, mixed value) : $this
set<ArgumentName>($value): mixed
where:
$value is the value being set by the user It returns the value to return to set in the $arguments array of the event.
since |
4.0.0 |
---|
Arguments
- name
string
Argument name.- value
mixed
Value.
Response
$this
Properties
eventNameToConcreteClass
Maps event names to concrete Event classes.
This is only for events with invariable names. Events with variable names are handled with PHP logic in the getEventClassByEventName class.
since |
4.2.0 |
---|
Type(s)
array