- ⌂ comand
- Configurations
- Methods
- Static Methods
comand::connect()
The connect method of a COMAND object provides a way to connect to a specific COMAND Repository.
Prototype
repository connect(array $options = [])
Parameters
- options - Optional associative array of repository connection options to override defaults.
These will override the connect options provided to the comand constructor.
- url - The URL of the COMAND repository host. The default is 'comand://localhost', which refers to the computer that is running the application. URL strings may include a valid protocol (comand, http or https), host (DNS hostname or IP address), port number (default is 80 for http and 443 for https) and path (ie. "/comand"). The 'comand' protocol is specified to connect directly to a local repository's storage engine(s), instead of the web service.
- auth - Authentication information and credentials. Password authentication is currently the only supported type, which requires the following three key/value pairs.
- type - Must be 'password', which indicates username/password authentication. Additional types of authentication may be introduced in the future, which may use additional or entirely different key/value pairs. All other key/value pairs are specific to specified type.
- username - The username of the COMAND repository user to connect with.
- password - The password, in plain text, of the COMAND repository user to connect with.
- mode - The mode to use when querying the repository. The mode is one of the following integer values.
- repo::MODE_ACTIVE (0) - The default mode. Queries will only return active (aka approved) objects from the repository. Draft and Working Copy versions of objects will be ignored and never returned in query results.
- repo::MODE_DRAFT (1) - Queries will return Draft objects from the repository. When a Draft does not exist, the Active version will be returned. Working Copy versions of objects will be ignored and never returned in query results.
- repo::MODE_WORKING (2) - The default mode in the Content Manager App. Queries will return Working Copy objects from the repository. When a Working Copy does not exist, a Draft will be returned. When a Working Copy and Draft do not exist, the Active version will be returned.
- timestamp - Time used to query content. All content queries will return content as it existed at the specified time. Timestamp in 'YYYY-MM-DD HH:MM:SS +HH:MM' string or unix timestamp (seconds since Epoch) format. Default is current time. For more information, see temporal queries.
- revision - Revision used to query content. All content queries will return content as it existed at the specified revision. Default is latest revision. For more information, see temporal queries.
- log_queries - Set to
TRUE
to log all storage engine queries to the system log. Useful for debugging storage engine queries. Default isFALSE
. - chain_log - Event log to chain the system log to.
- event_log_level - Default is
\comand\event\type::INFO
. - on_error - Determine what to do when an error event is logged. Options are:
- log_error - This is the default. Log the error to the event log.
- ThrowException - Throw an exception immediately when an error is logged.
- engine - Merge an existing storage engine configuration with the new one upon initialization.
Example
$options = [
'url' => 'comand://localhost', // this is the default
'auth' => [
'type' => 'password',
'username' => 'user',
'password' => 'pass'
],
'mode' => 0, // Active (the default)
];
$repo = $comand->connect( $options );
if( $repo ) {
echo( "Connected to " . $repo->hostname . "\n" );
// to disconnect: $repo->disconnect();
}