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
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
$bufferSize
Maximum length of a requst
private
int
$bufferSize
$pipes
private
array<string|int, mixed>
$pipes
$process
private
resource|false|null
$process
$welcome
private
array<string|int, mixed>|null
$welcome
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
__destruct()
public
__destruct() : mixed
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
.
close()
public
close() : void
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.
getBufferSize()
public
getBufferSize() : int
Return values
intgetWelcome()
public
getWelcome() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullsetBufferSize()
public
setBufferSize(int $bufferSize) : $this
Parameters
- $bufferSize : int