Back to AbstractEvent class

Method getArgument

public mixed
getArgument
(mixed $name, mixed $default = null)
Get an event argument value. It will use a getter method if one exists. The getters have the signature:
Parameters
  • string $name The argument name.
  • mixed $default The default value if not found.
Returns
  • mixed The argument value or the default value.
Since
  • 4.0.0
Class: AbstractEvent
Project: Joomla

Method getArgument - Source code

/**
 * Get an event argument value. It will use a getter method if one exists. The getters have the signature:
 *
 * 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.
 *
 * @param   string  $name     The argument name.
 * @param   mixed   $default  The default value if not found.
 *
 * @return  mixed  The argument value or the default value.
 *
 * @since   4.0.0
 */
public function getArgument($name, $default = null)
{
    $methodName = 'get' . ucfirst($name);
    $value = parent::getArgument($name, $default);
    if (method_exists($this, $methodName)) {
        return $this->{$methodName}($value);
    }
    return $value;
}