Since: 5.0.0

abstract class AbstractSaveEvent extends UserEvent

Base class for User save event

Traits

A Trait to reshape arguments maintaining b/c with legacy plugin events.

Returns the most suitable event class for a Joomla core event name

Properties

protected array deprecated Since: 5.0.0
$legacyArgumentsOrder

The argument names, in order expected by legacy plugins.

Methods

static string
getEventClassByEventName(string $eventName)

Get the concrete event class name for the given event name.

static AbstractEvent
create(string $eventName, array $arguments = [])

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.

__construct(string $name, array $arguments = [])

Constructor.

mixed
getArgument(string $name, mixed $default = null)

Get an event argument value.

$this
setArgument(string $name, mixed $value)

Add argument to event.

void
offsetSet(string $name, mixed $value)

Set the value of an event argument.

void
offsetUnset(string $name)

Remove an event argument.

array
reshapeArguments(array $arguments, array $argumentNames, array $defaults = [])

Reshape the arguments array to preserve b/c with legacy listeners

array
onSetSubject(array $value)

Setter for the subject argument.

bool
onSetIsNew(bool $value)

Setter for the isNew argument.

array
getUser()

Getter for the user.

bool
getIsNew()

Getter for the isNew state.

Details

static protected string getEventClassByEventName(string $eventName)

Since: 4.2.0

Get the concrete event class name for the given event name.

This method falls back to the generic Joomla\Event\Event class if the event name is unknown to this trait.

Parameters

string $eventName

The event name

Return Value

string

The event class name

static AbstractEvent create(string $eventName, array $arguments = [])

Since: 4.0.0

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.

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

Parameters

string $eventName

The name of the event, e.g. onTableBeforeLoad

array $arguments

Additional arguments to pass to the event

Return Value

AbstractEvent

Exceptions

BadMethodCallException

__construct(string $name, array $arguments = [])

Since: 5.0.0

Constructor.

Parameters

string $name

The event name.

array $arguments

The event arguments.

Exceptions

BadMethodCallException

mixed getArgument(string $name, mixed $default = null)

Since: 4.0.0

Get an event argument value.

It will use a pre-processing method if one exists. The method has the signature:

onGet($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.

Parameters

string $name

The argument name.

mixed $default

The default value if not found.

Return Value

mixed

The argument value or the default value.

$this setArgument(string $name, mixed $value)

Since: 4.0.0

Add argument to event.

It will use a pre-processing method if one exists. The method has the signature:

onSet($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.

Parameters

string $name

Argument name.

mixed $value Value.

Return Value

$this

void offsetSet(string $name, mixed $value)

Since: 4.0.0

Set the value of an event argument.

Parameters

string $name

The argument name.

mixed $value

The argument value.

Return Value

void

Exceptions

BadMethodCallException

void offsetUnset(string $name)

Since: 4.0.0

Remove an event argument.

Parameters

string $name

The argument name.

Return Value

void

Exceptions

BadMethodCallException

protected array reshapeArguments(array $arguments, array $argumentNames, array $defaults = [])

Since: 4.2.0

Reshape the arguments array to preserve b/c with legacy listeners

Parameters

array $arguments

The named arguments array passed to the constructor.

array $argumentNames

The allowed argument names (mandatory AND optional).

array $defaults

Default values for optional arguments.

Return Value

array

The reshaped arguments.

protected array onSetSubject(array $value)

Since: 5.0.0

Setter for the subject argument.

Parameters

array $value

The value to set

Return Value

array

protected bool onSetIsNew(bool $value)

Since: 5.0.0

Setter for the isNew argument.

Parameters

bool $value

The value to set

Return Value

bool

array getUser()

Since: 5.0.0

Getter for the user.

Return Value

array

bool getIsNew()

Since: 5.0.0

Getter for the isNew state.

Return Value

bool