/**
 * Gets a user state.
 *
 * @param   string  $key      The path of the state.
 * @param   mixed   $default  Optional default value, returned if the internal value is null.
 *
 * @return  mixed  The user state or null.
 *
 * @since   3.2
 */
public function getUserState($key, $default = null)
{
    $registry = $this->getSession()->get('registry');
    if ($registry !== null) {
        return $registry->get($key, $default);
    }
    return $default;
}