Back to CMSApplication class

Method getUserStateFromRequest

public mixed
getUserStateFromRequest
(mixed $key, mixed $request, mixed $default = null, mixed $type = 'none')
Gets the value of a user state variable.
Parameters
  • string $key The key of the user state variable.
  • string $request The name of the variable passed in a request.
  • string $default The default value for the variable if not found. Optional.
  • string $type Filter for the variable, for valid values see {@link InputFilter::clean()}. Optional.
Returns
  • mixed The request user state.
Since
  • 3.2

Method getUserStateFromRequest - Source code

/**
 * Gets the value of a user state variable.
 *
 * @param   string  $key      The key of the user state variable.
 * @param   string  $request  The name of the variable passed in a request.
 * @param   string  $default  The default value for the variable if not found. Optional.
 * @param   string  $type     Filter for the variable, for valid values see {@link InputFilter::clean()}. Optional.
 *
 * @return  mixed  The request user state.
 *
 * @since   3.2
 */
public function getUserStateFromRequest($key, $request, $default = null, $type = 'none')
{
    $cur_state = $this->getUserState($key, $default);
    $new_state = $this->input->get($request, null, $type);
    if ($new_state === null) {
        return $cur_state;
    }
    // Save the new value only if it was set in this request.
    $this->setUserState($key, $new_state);
    return $new_state;
}