FOF30\Model\Model::getState PHP Method

getState() public method

Get a filtered state variable
public getState ( string $key = null, mixed $default = null, string $filter_type = 'raw' ) : mixed
$key string The state variable's name
$default mixed The default value to return if it's not already set
$filter_type string The filter type to use
return mixed The state variable's contents
    public function getState($key = null, $default = null, $filter_type = 'raw')
    {
        if (empty($key)) {
            return $this->internal_getState();
        }
        // Get the savestate status
        $value = $this->internal_getState($key);
        // Value is not found in the internal state
        if (is_null($value)) {
            // Can I fetch it from the request?
            if (!$this->_ignoreRequest) {
                $value = $this->container->platform->getUserStateFromRequest($this->getHash() . $key, $key, $this->input, $value, 'none', $this->_savestate);
                // Did I get any useful value from the request?
                if (is_null($value)) {
                    return $default;
                }
            } else {
                return $default;
            }
        }
        if (strtoupper($filter_type) == 'RAW') {
            return $value;
        } else {
            $filter = new \JFilterInput();
            return $filter->clean($value, $filter_type);
        }
    }