ErrorEvent

Extends \Joomla\CMS\Event\AbstractEvent

Event class for representing the application's `onError` event

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

Methods

__construct

Constructor. Overridden to go through the argument setters.

__construct(string $name, array $arguments = array()) 
inherited
since

4.0.0

Arguments

$name

stringThe event name.

$arguments

arrayThe event arguments.

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 = array()) : static
inherited static

eventClass string The Event class name. If you do not provide it Joomla\CMS\Events\ will be used.

since

4.0.0

throws

\BadMethodCallExceptionIf you do not provide a subject argument

Arguments

$eventName

stringThe name of the event, e.g. onTableBeforeLoad

$arguments

arrayAdditional arguments to pass to the event

Response

static

getApplication

Get the event's application object

getApplication() : \Joomla\Application\AbstractApplication
since

4.0.0

Response

\Joomla\Application\AbstractApplication

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
inherited

get($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

stringThe argument name.

$default

mixedThe default value if not found.

Response

mixedThe argument value or the default value.

getError

Get the event's error object

getError() : \Throwable
since

4.0.0

Response

\Throwable

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
inherited

set($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

stringArgument name.

$value

mixedValue.

Response

$this

setError

Set the event's error object

setError(\Throwable $error) : void
since

4.0.0

Arguments

$error

\ThrowableThe new error to process