Perforce Chronicle 2012.2/486814
API Documentation
|
A mechanism for providing an connection that will be loaded on-demand. More...
Public Member Functions | |
__construct ($callback=null, $ignored1=null, $ignored2=null, $ignored3=null, $ignored4=null) | |
Create a new deferred connection from the given callback. | |
addDisconnectCallback ($callback, $persistent=false) | |
Add a function to run when connection is closed. | |
batchArgs (array $arguments, array $prefixArgs=null, array $suffixArgs=null, $groupSize=1) | |
Return arguments split into chunks (batches) where each batch contains as many arguments as possible to not exceed ARG_MAX or OPTION_LIMIT. | |
connect () | |
Connect to a Perforce server. | |
disconnect () | |
Disconnect from a Perforce server. | |
getAppName () | |
Get the application name being reported to the server. | |
getArgMax () | |
Get the maximum allowable length of all command arguments. | |
getCharset () | |
Retrieves the character set used by this connection. | |
getClient () | |
Return the p4 user's client. | |
getClientRoot () | |
Get the current client's root directory. | |
getConnection () | |
Resolves the callback to a real connection. | |
getConnectionIdentity () | |
Get the identity of this Connection implementation. | |
getHost () | |
Retrieves the client host set for this connection. | |
getInfo () | |
Return an array of connection information. | |
getPassword () | |
Retrieves the password set for this perforce connection. | |
getPort () | |
Return the p4 port. | |
getSecurityLevel () | |
Get the server's security level. | |
getTicket () | |
Retrieves the ticket set for this perforce connection. | |
getUser () | |
Return the name of the p4 user. | |
isCaseSensitive () | |
Check if the server we are connected to is case sensitive. | |
isConnected () | |
Check connected state. | |
isSuperUser () | |
Check if the user we are connected as has super user privileges. | |
login () | |
Authenticate the user with 'p4 login'. | |
run ($command, $params=array(), $input=null, $tagged=true) | |
Executes the specified command and returns a perforce result object. | |
setAppName ($name) | |
Set the name of the application that is using this connection. | |
setCallback ($callback) | |
Set the callback to use to get the real connection to use. | |
setCharset ($charset) | |
Sets the character set to use for this perforce connection. | |
setClient ($client) | |
Set the p4 user's client. | |
setHost ($host) | |
Sets the client host name overriding the environment. | |
setPassword ($password) | |
Sets the password to use for this perforce connection. | |
setPort ($port) | |
Set the p4 port. | |
setTicket ($ticket) | |
Sets the ticket to use for this perforce connection. | |
setUser ($user) | |
Set the name of the p4 user. | |
Protected Attributes | |
$_callback = null |
A mechanism for providing an connection that will be loaded on-demand.
This is particularly useful if creating the connection will have notable expense you wish to avoid, or if you expect the connection may change.
P4_Connection_Deferred::__construct | ( | $ | callback = null , |
$ | ignored1 = null , |
||
$ | ignored2 = null , |
||
$ | ignored3 = null , |
||
$ | ignored4 = null |
||
) |
Create a new deferred connection from the given callback.
A callback must be provided.
callable | $callback | the callback function to get the real connection. |
string | $ignored1 | unused argument required by interface. |
string | $ignored2 | unused argument required by interface. |
string | $ignored3 | unused argument required by interface. |
string | $ignored4 | unused argument required by interface. |
InvalidArgumentException | if the given callback is not callable. |
Implements P4_Connection_Interface.
{ $this->setCallback($callback); }
P4_Connection_Deferred::addDisconnectCallback | ( | $ | callback, |
$ | persistent = false |
||
) |
Add a function to run when connection is closed.
Callbacks are removed after they are executed unless persistent is set to true.
callable | $callback | the function to execute on disconnect (will be passed connection). |
bool | $persistent | optional - defaults to false - set to true to run callback on repeated disconnects. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->addDisconnectCallback($callback, $persistent); }
P4_Connection_Deferred::batchArgs | ( | array $ | arguments, |
array $ | prefixArgs = null , |
||
array $ | suffixArgs = null , |
||
$ | groupSize = 1 |
||
) |
Return arguments split into chunks (batches) where each batch contains as many arguments as possible to not exceed ARG_MAX or OPTION_LIMIT.
ARG_MAX is a character limit that affects command line programs (p4). OPTION_LIMIT is a server-side limit on the number of flags (e.g. '-n').
array | $arguments | list of arguments to split into chunks. |
array | null | $prefixArgs | arguments to begin all batches with. |
array | null | $suffixArgs | arguments to end all batches with. |
int | $groupSize | keep arguments together in groups of this size for example, when clearing attributes you want to keep pairs of -n and attr-name together. |
P4_Exception | if a argument (or set of arguments) exceed arg-max. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->batchArgs($arguments, $prefixArgs, $suffixArgs, $groupSize); }
P4_Connection_Deferred::connect | ( | ) |
Connect to a Perforce server.
P4_Connection_ConnectException | if the connection fails. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->connect(); }
P4_Connection_Deferred::disconnect | ( | ) |
Disconnect from a Perforce server.
Implements P4_Connection_Interface.
{ return $this->getConnection()->disconnect(); }
P4_Connection_Deferred::getAppName | ( | ) |
Get the application name being reported to the server.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getAppName(); }
P4_Connection_Deferred::getArgMax | ( | ) |
Get the maximum allowable length of all command arguments.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getArgMax(); }
P4_Connection_Deferred::getCharset | ( | ) |
Retrieves the character set used by this connection.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getCharset(); }
P4_Connection_Deferred::getClient | ( | ) |
Return the p4 user's client.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getClient(); }
P4_Connection_Deferred::getClientRoot | ( | ) |
Get the current client's root directory.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getClientRoot(); }
P4_Connection_Deferred::getConnection | ( | ) |
Resolves the callback to a real connection.
P4_Exception | if callback fails to return a proper connection. |
{ $adapter = call_user_func($this->_callback); if (!$adapter instanceof P4_Connection_Interface) { throw new P4_Exception( "Cannot resolve deferred connection. Callback failed to return a proper connection." ); } return $adapter; }
P4_Connection_Deferred::getConnectionIdentity | ( | ) |
Get the identity of this Connection implementation.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getConnectionIdentity(); }
P4_Connection_Deferred::getHost | ( | ) |
Retrieves the client host set for this connection.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getHost(); }
P4_Connection_Deferred::getInfo | ( | ) |
Return an array of connection information.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getInfo(); }
P4_Connection_Deferred::getPassword | ( | ) |
Retrieves the password set for this perforce connection.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getPassword(); }
P4_Connection_Deferred::getPort | ( | ) |
Return the p4 port.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getPort(); }
P4_Connection_Deferred::getSecurityLevel | ( | ) |
Get the server's security level.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getSecurityLevel(); }
P4_Connection_Deferred::getTicket | ( | ) |
Retrieves the ticket set for this perforce connection.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getTicket(); }
P4_Connection_Deferred::getUser | ( | ) |
Return the name of the p4 user.
Implements P4_Connection_Interface.
{ return $this->getConnection()->getUser(); }
P4_Connection_Deferred::isCaseSensitive | ( | ) |
Check if the server we are connected to is case sensitive.
Implements P4_Connection_Interface.
{ return $this->getConnection()->isCaseSensitive(); }
P4_Connection_Deferred::isConnected | ( | ) |
Check connected state.
Implements P4_Connection_Interface.
{ return $this->getConnection()->isConnected(); }
P4_Connection_Deferred::isSuperUser | ( | ) |
Check if the user we are connected as has super user privileges.
Implements P4_Connection_Interface.
{ return $this->getConnection()->isSuperUser(); }
P4_Connection_Deferred::login | ( | ) |
Authenticate the user with 'p4 login'.
P4_Connection_LoginException | if login fails. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->login(); }
P4_Connection_Deferred::run | ( | $ | command, |
$ | params = array() , |
||
$ | input = null , |
||
$ | tagged = true |
||
) |
Executes the specified command and returns a perforce result object.
No need to call connect() first. Run will connect automatically.
string | $command | the command to run. |
array | string | $params | optional - one or more arguments. |
array | string | $input | optional - input for the command - should be provided in array form when writing perforce spec records. |
boolean | $tagged | optional - true/false to enable/disable tagged output. defaults to true. |
P4_Connection_CommandException | if the command fails. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->run($command, $params, $input, $tagged); }
P4_Connection_Deferred::setAppName | ( | $ | name | ) |
Set the name of the application that is using this connection.
The application name will be reported to the server and might be necessary to satisfy certain licensing restrictions.
string | null | $name | the app name to report to the server. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->setAppName($name); }
P4_Connection_Deferred::setCallback | ( | $ | callback | ) |
Set the callback to use to get the real connection to use.
callable | $callback | the callback function to get the real connection. the callback will be called with no arguments and must return a connection instance. |
InvalidArgumentException | if the given callback is not callable. |
{ if (!is_callable($callback)) { throw new InvalidArgumentException( "Cannot set callback. Given callback is not callable." ); } $this->_callback = $callback; return $this; }
P4_Connection_Deferred::setCharset | ( | $ | charset | ) |
Sets the character set to use for this perforce connection.
You should only set a character set when connecting to a 'unicode enabled' server.
string | $charset | the charset to use (e.g. 'utf8'). |
Implements P4_Connection_Interface.
{ return $this->getConnection()->setCharset($charset); }
P4_Connection_Deferred::setClient | ( | $ | client | ) |
Set the p4 user's client.
string | $client | the name of the client workspace to use. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->setClient($client); }
P4_Connection_Deferred::setHost | ( | $ | host | ) |
Sets the client host name overriding the environment.
string | null | $host | the host name to use. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->setHost($host); }
P4_Connection_Deferred::setPassword | ( | $ | password | ) |
Sets the password to use for this perforce connection.
string | $password | the password to use as authentication. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->setPassword($password); }
P4_Connection_Deferred::setPort | ( | $ | port | ) |
Set the p4 port.
string | $port | the port to connect to. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->setPort($port); }
P4_Connection_Deferred::setTicket | ( | $ | ticket | ) |
Sets the ticket to use for this perforce connection.
string | $ticket | the ticket to use as authentication. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->setTicket($ticket); }
P4_Connection_Deferred::setUser | ( | $ | user | ) |
Set the name of the p4 user.
string | $user | the user to connect as. |
Implements P4_Connection_Interface.
{ return $this->getConnection()->setUser($user); }
P4_Connection_Deferred::$_callback = null [protected] |