Perforce Chronicle 2012.2/486814
API Documentation
|
Base class for all Perforce models. More...
Public Member Functions | |
__construct (P4_Connection_Interface $connection=null) | |
Instantiate the model and set the connection to use. | |
__sleep () | |
We need a custom sleep to exclude the connection property. | |
clearConnection () | |
Clear this model's connection. | |
getConnection () | |
Get the Perforce connection used by this model. | |
hasConnection () | |
Determine if this model has a connection to Perforce. | |
setConnection (P4_Connection_Interface $connection) | |
Set the Perforce connection to use when issuing Perforce commands for this instance. | |
Static Public Member Functions | |
static | getDefaultConnection () |
Get the default Perforce connection to use. | |
Protected Attributes | |
$_connection = null |
Base class for all Perforce models.
Provides get/set Perforce connection capabilities. This allows a specific perforce connection to be set on a per-object basis.
To set the perforce connection to use for a particular instance, pass a connection to the constructor or call setConnection() on the object if it already exists.
P4_ConnectedAbstract::__construct | ( | P4_Connection_Interface $ | connection = null | ) |
Instantiate the model and set the connection to use.
P4_Connection_Interface | $connection | optional - a connection to use for this instance. |
Implements P4_ConnectedInterface.
{ if ($connection) { $this->setConnection($connection); } else if (P4_Connection::hasDefaultConnection()) { $this->setConnection(P4_Connection::getDefaultConnection()); } }
P4_ConnectedAbstract::__sleep | ( | ) |
We need a custom sleep to exclude the connection property.
Connection objects cannot be serialized.
{ return array_diff( array_keys(get_object_vars($this)), array('_connection') ); }
P4_ConnectedAbstract::clearConnection | ( | ) |
Clear this model's connection.
This is primarily for testing purposes.
Implements P4_ConnectedInterface.
{ $this->_connection = null; }
P4_ConnectedAbstract::getConnection | ( | ) |
Get the Perforce connection used by this model.
Implements P4_ConnectedInterface.
{ if ($this->_connection instanceof P4_Connection_Interface) { return $this->_connection; } throw new P4_Exception("Cannot get connection. No connection is set."); }
static P4_ConnectedAbstract::getDefaultConnection | ( | ) | [static] |
Get the default Perforce connection to use.
Implements P4_ConnectedInterface.
{ return P4_Connection::getDefaultConnection(); }
P4_ConnectedAbstract::hasConnection | ( | ) |
Determine if this model has a connection to Perforce.
Implements P4_ConnectedInterface.
{ try { $this->getConnection(); return true; } catch (P4_Exception $e) { return false; } }
P4_ConnectedAbstract::setConnection | ( | P4_Connection_Interface $ | connection | ) |
Set the Perforce connection to use when issuing Perforce commands for this instance.
P4_Connection_Interface | $connection | the connection to use for this instance. |
Implements P4_ConnectedInterface.
{
$this->_connection = $connection;
return $this;
}
P4_ConnectedAbstract::$_connection = null [protected] |