ResultAware
This Trait partially implements the ResultAwareInterface for mutable and immutable events.
You must additionally implement the typeCheckResult method or use one of the ResultType*Aware traits in your Event handler.
since |
4.2.0 |
---|---|
package |
Joomla CMS |
Methods
addResult
Appends data to the result array of the event.
addResult( data) :
since |
4.2.0 |
---|
Arguments
- data
mixed
What to add to the result array.
Response
void
onSetResult
Handle setting the result argument directly.
onSetResult(mixed||string|int value) : mixed||string|int
This method serves a dual purpose: backwards compatibility and enforcing the use of addResult.
When $this->preventSetArgumentResult is false it acts as a backwards compatibility shim for event handlers expecting generic event classes instead of the concrete Events implemented in this package. This allows the migration to concrete event classes throughout the lifetime of Joomla 4.x.
When $this->preventSetArgumentResult is false (which will always be the case on Joomla 5.0) it will throw a BadMethodCallException if the developer tries to call setArgument('result', ...) instead of going through the addResult() method.
since |
4.4.0 |
---|
Arguments
- value
array<string|int, mixed>
The new result array.
Response
array<string|int, mixed>
setResult
Handle setting the result argument directly.
setResult(mixed||string|int value) : mixed||string|int
This method serves a dual purpose: backwards compatibility and enforcing the use of addResult.
When $this->preventSetArgumentResult is false it acts as a backwards compatibility shim for event handlers expecting generic event classes instead of the concrete Events implemented in this package. This allows the migration to concrete event classes throughout the lifetime of Joomla 4.x.
When $this->preventSetArgumentResult is false (which will always be the case on Joomla 5.0) it will throw a BadMethodCallException if the developer tries to call setArgument('result', ...) instead of going through the addResult() method.
since |
4.2.0 |
---|---|
deprecated |
4.4.0 will be removed in 6.0 Use counterpart with onSet prefix |
Arguments
- value
array<string|int, mixed>
The new result array.
Response
array<string|int, mixed>
Properties
preventSetArgumentResult
Disallow setting the result argument directly with setArgument() instead of going through addResult().
You should set this to true ONLY for event names which did NOT exist before Joomla 4.2.0 or if you are a third party developer introducing new event names for use only in your software.
since |
4.2.0 |
---|---|
deprecated |
4.3 will be removed in 6.0 Using setResult() for the result argument will always be disallowed. |
Type(s)
bool