Documentation

BasicPipeClient
in package

This is a thin/trivial client implementation that connects to Civi::pipe() and synchronously exchanges JSON messages.

It is intended for use E2E testing.

Tags
code

$rpc = new BasicPipeClient('drush ev 'civicrm_initialize(); Civi::pipe();''); $rpc->call('login', ['contactId' => 202]); $contacts = $rpc->call('api4', ['Contact', 'get']);

endCode

Failed method-calls will emit JsonRpcMethodException. Errors in protocol handling will emit RuntimeExcpetion.

Table of Contents

Properties

$bufferSize  : int
Maximum length of a requst
$pipes  : array<string|int, mixed>
$process  : resource|false|null
$welcome  : array<string|int, mixed>|null

Methods

__construct()  : mixed
__destruct()  : mixed
call()  : array{result: array, error: array, jsonrpc: string, id: string|int|null}
Call a method and return the result.
close()  : void
connect()  : array<string|int, mixed>
Start a worker process.
getBufferSize()  : int
getWelcome()  : array<string|int, mixed>|null
setBufferSize()  : $this

Properties

Methods

__construct()

public __construct([string|null $command = NULL ][, int $bufferSize = 32767 ]) : mixed
Parameters
$command : string|null = NULL

The shell command to start the pipe. If given, auto-connect. If omitted, then you can call connect($command) later. Ex: cv ev 'Civi::pipe();', cv ev 'Civi::pipe("u");', drush ev 'civicrm_initialize(); Civi::pipe("vt");'

$bufferSize : int = 32767

call()

Call a method and return the result.

public call(string $method, array<string|int, mixed> $params[, string|int|null $id = NULL ]) : array{result: array, error: array, jsonrpc: string, id: string|int|null}
Parameters
$method : string
$params : array<string|int, mixed>
$id : string|int|null = NULL
Return values
array{result: array, error: array, jsonrpc: string, id: string|int|null}

The JSON-RPC response recrd. Contains result or error.

connect()

Start a worker process.

public connect(string $command) : array<string|int, mixed>
Parameters
$command : string

The shell command to start the pipe. Ex: cv ev 'Civi::pipe();', cv ev 'Civi::pipe("u");', drush ev 'civicrm_initialize(); Civi::pipe("vt");'

Return values
array<string|int, mixed>

Returns the header/welcome message for the connection.

getWelcome()

public getWelcome() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

setBufferSize()

public setBufferSize(int $bufferSize) : $this
Parameters
$bufferSize : int
Return values
$this

        
On this page

Search results