PHP Class Jackalope\Transport\Jackrabbit\Request

Author: Christian Stocker ([email protected])
Author: David Buchmann ([email protected])
Author: Roland Schilter ([email protected])
Author: Jordi Boggiano ([email protected])
Author: Lukas Kahwe Smith ([email protected])
Author: Markus Schmucker ([email protected])
Show file Open project: jackalope/jackalope-jackrabbit

Protected Properties

Property Type Description
$additionalHeaders
$body string Posted content for methods that require it
$client Client
$contentType string Request content-type
$credentials PHPCR\CredentialsInterface Set of credentials necessary to connect to the server or else.
$curl Jackalope\Transport\Jackrabbit\curl
$depth integer How far the request should go, default is 0
$errorHandlingMode boolean Whether we are in error handling mode to prevent infinite recursion
$lockToken string | FALSE The lock token active for this request otherwise FALSE for no locking
$method string Name of the request method to be used.
$uri array .
$versionChecked boolean Doing this once per php process is enough.

Public Methods

Method Description
__construct ( Jackalope\FactoryInterface $factory, Client $client, Jackalope\Transport\Jackrabbit\curl $curl, string $method, string | array $uri ) Initiaties the NodeTypes request object.
addCurlOptions ( array $options ) Add curl-options for this request.
addHeader ( string $header ) add an additional http header
addUserData ( string $userData ) Add the user data header
execute ( boolean $getCurlObject = false, boolean $forceMultiple = false ) : string | Jackalope\Transport\Jackrabbit\curl | array Requests the data to be identified by a formerly prepared request.
executeDom ( boolean $forceMultiple = false ) : DOMDocument Loads the response into an DOMDocument.
executeJson ( boolean $forceMultiple = false ) : mixed Loads the server response as a json string.
forceHttpVersion10 ( ) Force curl to use HTTP version 1.0
setBody ( string $body ) Set the request body
setContentType ( string $contentType ) Set a different content type for this request. The default is text/xml in utf-8
setCredentials ( PHPCR\CredentialsInterface $creds = null ) Set the credentials for the request. Setting them to null will make a request without authentication header.
setDepth ( integer | string $depth ) Set the depth to which nodes should be fetched.
setLockToken ( string $lockToken ) Set the transaction lock token to be used with this request
setMethod ( string $method ) Set or update the HTTP method to be used in this request.
setUri ( string | array $uri )

Protected Methods

Method Description
getLongErrorString ( Jackalope\Transport\Jackrabbit\curl $curl, string $response ) : string returns a longer error string to be used in generic exceptions
getShortErrorString ( ) : string returns a shorter error string to be used in exceptions
handleError ( Jackalope\Transport\Jackrabbit\curl $curl, string $response, integer $httpCode ) Handles errors caused by singleRequest and multiRequest
multiRequest ( boolean $getCurlObject = false ) : array Requests the data for multiple requests
prepareCurl ( Jackalope\Transport\Jackrabbit\curl $curl, boolean $getCurlObject ) used by multiCurl with fresh curl instances
singleRequest ( boolean $getCurlObject ) : string | Jackalope\Transport\Jackrabbit\curl Requests the data for a single requests

Method Details

__construct() public method

Initiaties the NodeTypes request object.
public __construct ( Jackalope\FactoryInterface $factory, Client $client, Jackalope\Transport\Jackrabbit\curl $curl, string $method, string | array $uri )
$factory Jackalope\FactoryInterface Ignored for now, as this class does not create objects
$client Client The jackrabbit client instance
$curl Jackalope\Transport\Jackrabbit\curl The cURL object to use in this request
$method string the HTTP method to use, one of the class constants
$uri string | array the remote url for this request, including protocol, host name, workspace and path to the object to manipulate. May be an array of uri

addCurlOptions() public method

Add curl-options for this request.
public addCurlOptions ( array $options )
$options array

addHeader() public method

add an additional http header
public addHeader ( string $header )
$header string HTTP header

addUserData() public method

Add the user data header
public addUserData ( string $userData )
$userData string

execute() public method

Prepares the curl object, executes it and checks for transport level errors, throwing the appropriate exceptions.
public execute ( boolean $getCurlObject = false, boolean $forceMultiple = false ) : string | Jackalope\Transport\Jackrabbit\curl | array
$getCurlObject boolean wheter to return the curl object instead of the response
$forceMultiple boolean whether to force parallel requests or not
return string | Jackalope\Transport\Jackrabbit\curl | array response string or the curl object.

executeDom() public method

Returns a DOMDocument from the backend or throws exception. Does error handling for both connection errors and dcr:exception response
public executeDom ( boolean $forceMultiple = false ) : DOMDocument
$forceMultiple boolean whether to force parallel requests or not
return DOMDocument The loaded XML response text.

executeJson() public method

Returns a decoded json string from the backend or throws exception
public executeJson ( boolean $forceMultiple = false ) : mixed
$forceMultiple boolean whether to force parallel requests or not
return mixed

forceHttpVersion10() public method

Force curl to use HTTP version 1.0
Deprecation: use addCurlOptions([CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0]) instead
public forceHttpVersion10 ( )

getLongErrorString() protected method

It returns a "nicely" formatted URI of the request plus the output of curl_getinfo plus the response body including its size
protected getLongErrorString ( Jackalope\Transport\Jackrabbit\curl $curl, string $response ) : string
$curl Jackalope\Transport\Jackrabbit\curl The curl object
$response string the response body
return string the error message

getShortErrorString() protected method

It returns a "nicely" formatted URI of the request
protected getShortErrorString ( ) : string
return string the error message

handleError() protected method

For transport level errors, tries to figure out what went wrong to throw the most appropriate exception.
protected handleError ( Jackalope\Transport\Jackrabbit\curl $curl, string $response, integer $httpCode )
$curl Jackalope\Transport\Jackrabbit\curl
$response string the response body
$httpCode integer the http response code

multiRequest() protected method

Requests the data for multiple requests
protected multiRequest ( boolean $getCurlObject = false ) : array
$getCurlObject boolean whether to return the curl object instead of the response
return array of XML representations of responses or curl objects.

prepareCurl() protected method

used by multiCurl with fresh curl instances
protected prepareCurl ( Jackalope\Transport\Jackrabbit\curl $curl, boolean $getCurlObject )
$curl Jackalope\Transport\Jackrabbit\curl
$getCurlObject boolean whether to return the curl object instead of the response

setBody() public method

Set the request body
public setBody ( string $body )
$body string

setContentType() public method

Set a different content type for this request. The default is text/xml in utf-8
public setContentType ( string $contentType )
$contentType string

setCredentials() public method

Set the credentials for the request. Setting them to null will make a request without authentication header.
public setCredentials ( PHPCR\CredentialsInterface $creds = null )
$creds PHPCR\CredentialsInterface the credentials to use in the request.

setDepth() public method

To support more than 0, we need to implement more logic in parsing the response too.
public setDepth ( integer | string $depth )
$depth integer | string

setLockToken() public method

Set the transaction lock token to be used with this request
public setLockToken ( string $lockToken )
$lockToken string the transaction lock

setMethod() public method

Set or update the HTTP method to be used in this request.
public setMethod ( string $method )
$method string the HTTP method to use, one of the class constants

setUri() public method

public setUri ( string | array $uri )
$uri string | array the request target

singleRequest() protected method

Requests the data for a single requests
protected singleRequest ( boolean $getCurlObject ) : string | Jackalope\Transport\Jackrabbit\curl
$getCurlObject boolean whether to return the curl object instead of the response
return string | Jackalope\Transport\Jackrabbit\curl XML representation of a response or curl object.

Property Details

$additionalHeaders protected property

protected $additionalHeaders

$body protected property

Posted content for methods that require it
protected string $body
return string

$client protected property

protected Client,Jackalope\Transport\Jackrabbit $client
return Client

$contentType protected property

Request content-type
protected string $contentType
return string

$credentials protected property

Set of credentials necessary to connect to the server or else.
protected CredentialsInterface,PHPCR $credentials
return PHPCR\CredentialsInterface

$curl protected property

protected curl,Jackalope\Transport\Jackrabbit $curl
return Jackalope\Transport\Jackrabbit\curl

$depth protected property

How far the request should go, default is 0
protected int $depth
return integer

$errorHandlingMode protected property

Whether we are in error handling mode to prevent infinite recursion
protected bool $errorHandlingMode
return boolean

$lockToken protected property

The lock token active for this request otherwise FALSE for no locking
protected string|FALSE $lockToken
return string | FALSE

$method protected property

Name of the request method to be used.
protected string $method
return string

$uri protected property

.
protected array $uri
return array

$versionChecked protected static property

Doing this once per php process is enough.
protected static bool $versionChecked
return boolean