Perforce Chronicle 2012.2/486814
API Documentation

P4_Connection_Interface Interface Reference

Provides a mechanism for running Perforce commands. More...

Inheritance diagram for P4_Connection_Interface:
P4_Connection_Abstract P4_Connection_Deferred P4_Connection_CommandLine P4_Connection_Extension

List of all members.

Public Member Functions

 __construct ($port=null, $user=null, $client=null, $password=null, $ticket=null)
 Create a P4_Connection_Interface instance.
 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.
 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.
 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.

Detailed Description

Provides a mechanism for running Perforce commands.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Constructor & Destructor Documentation

P4_Connection_Interface::__construct ( port = null,
user = null,
client = null,
password = null,
ticket = null 
)

Create a P4_Connection_Interface instance.

Parameters:
string$portoptional - the port to connect to.
string$useroptional - the user to connect as.
string$clientoptional - the client spec to use.
string$passwordoptional - the password to use.
string$ticketoptional - a ticket to use.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.


Member Function Documentation

P4_Connection_Interface::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.

Parameters:
callable$callbackthe function to execute on disconnect (will be passed connection).
bool$persistentoptional - defaults to false - set to true to run callback on repeated disconnects.
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::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').

Parameters:
array$argumentslist of arguments to split into chunks.
array | null$prefixArgsarguments to begin all batches with.
array | null$suffixArgsarguments to end all batches with.
int$groupSizekeep arguments together in groups of this size for example, when clearing attributes you want to keep pairs of -n and attr-name together.
Returns:
array list of batches of arguments where every batch contains as many arguments as possible and arg-max is not exceeded.
Exceptions:
P4_Exceptionif a argument (or set of arguments) exceed arg-max.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::connect ( )

Connect to a Perforce server.

Returns:
P4_Connection_Interface provides fluent interface.
Exceptions:
P4_Connection_ConnectExceptionif the connection fails.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::disconnect ( )

Disconnect from a Perforce server.

Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_CommandLine, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::getAppName ( )

Get the application name being reported to the server.

Returns:
string|null the app name reported to the server.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getArgMax ( )

Get the maximum allowable length of all command arguments.

Returns:
int the max length of combined arguments - zero for no limit

Implemented in P4_Connection_Abstract, P4_Connection_CommandLine, and P4_Connection_Deferred.

P4_Connection_Interface::getCharset ( )

Retrieves the character set used by this connection.

Returns:
string charset used for this connection.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getClient ( )

Return the p4 user's client.

Returns:
string the client.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getClientRoot ( )

Get the current client's root directory.

Returns:
string the full path to the current client's root.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getConnectionIdentity ( )

Get the identity of this Connection implementation.

Returns:
array an array of client Connection information containing the name, platform, version, build and date of the client library.

Implemented in P4_Connection_CommandLine, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::getHost ( )

Retrieves the client host set for this connection.

Returns:
string charset used for this connection.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getInfo ( )

Return an array of connection information.

Returns:
array the connection information ('p4 info').

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getPassword ( )

Retrieves the password set for this perforce connection.

Returns:
string password used to authenticate against perforce server.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getPort ( )

Return the p4 port.

Returns:
string the port.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getSecurityLevel ( )

Get the server's security level.

Returns:
int the security level of the server (e.g. 0, 1, 2, 3)

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getTicket ( )

Retrieves the ticket set for this perforce connection.

Returns:
string ticket as generated by perforce server.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::getUser ( )

Return the name of the p4 user.

Returns:
string the user.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::isCaseSensitive ( )

Check if the server we are connected to is case sensitive.

Returns:
bool true if the server is case sensitive, false otherwise.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::isConnected ( )

Check connected state.

Returns:
bool true if connected, false otherwise.

Implemented in P4_Connection_CommandLine, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::isSuperUser ( )

Check if the user we are connected as has super user privileges.

Returns:
bool true if the user has super, false otherwise.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::login ( )

Authenticate the user with 'p4 login'.

Returns:
string|null the ticket issued by the server or null if no ticket issued (user has no password).
Exceptions:
P4_Connection_LoginExceptionif login fails.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::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.

Parameters:
string$commandthe command to run.
array | string$paramsoptional - one or more arguments.
array | string$inputoptional - input for the command - should be provided in array form when writing perforce spec records.
boolean$taggedoptional - true/false to enable/disable tagged output. defaults to true.
Returns:
P4_Result the perforce result object.
Exceptions:
P4_Connection_CommandExceptionif the command fails.

Implemented in P4_Connection_Abstract, and P4_Connection_Deferred.

P4_Connection_Interface::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.

Parameters:
string | null$namethe app name to report to the server.
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::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.

Parameters:
string$charsetthe charset to use (e.g. 'utf8').
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::setClient ( client)

Set the p4 user's client.

Parameters:
string$clientthe name of the client workspace to use.
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::setHost ( host)

Sets the client host name overriding the environment.

Parameters:
string | null$hostthe host name to use.
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::setPassword ( password)

Sets the password to use for this perforce connection.

Parameters:
string$passwordthe password to use as authentication.
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::setPort ( port)

Set the p4 port.

Parameters:
string$portthe port to connect to.
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::setTicket ( ticket)

Sets the ticket to use for this perforce connection.

Parameters:
string$ticketthe ticket to use as authentication.
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.

P4_Connection_Interface::setUser ( user)

Set the name of the p4 user.

Parameters:
string$userthe user to connect as.
Returns:
P4_Connection_Interface provides fluent interface.

Implemented in P4_Connection_Abstract, P4_Connection_Deferred, and P4_Connection_Extension.


The documentation for this interface was generated from the following file: