lithium\data\Source::isConnected PHP Method

isConnected() public method

Checks the connection status of this data source. If the 'autoConnect' option is set to true and the source connection is not currently active, a connection attempt will be made before returning the result of the connection status.
public isConnected ( array $options = [] ) : boolean
$options array The options available for this method: - 'autoConnect': If true, and the connection is not currently active, calls `connect()` on this object. Defaults to `false`.
return boolean Returns the current value of `$_isConnected`, indicating whether or not the object's connection is currently active. This value may not always be accurate, as the connection could have timed out or otherwise been dropped by the remote resource during the course of the request.
    public function isConnected(array $options = array())
    {
        $defaults = array('autoConnect' => false);
        $options += $defaults;
        if (!$this->_isConnected && $options['autoConnect']) {
            try {
                $this->connect();
            } catch (NetworkException $e) {
                $this->_isConnected = false;
            }
        }
        return $this->_isConnected;
    }