Constants

HEAD

HEAD

POST

POST

PUT

PUT

GET

GET

DELETE

DELETE

DEFAULT_CONTENT_TYPE

DEFAULT_CONTENT_TYPE

NDJSON_CONTENT_TYPE

NDJSON_CONTENT_TYPE

Properties

$_params

$_params : array

Params.

Type

array

$_rawParams

$_rawParams : array

Raw Params.

Type

array

Methods

toArray()

toArray() : array

Converts the params to an array. A default implementation exist to create the an array out of the class name (last part of the class name) and the params.

Returns

array

setParam()

setParam(string  $key, mixed  $value) : $this

Sets (overwrites) the value at the given key.

Parameters

string $key

Key to set

mixed $value

Key Value

Returns

$this

setParams()

setParams(array  $params) : $this

Sets (overwrites) all params of this object.

Parameters

array $params

Parameter list

Returns

$this

addParam()

addParam(string  $key, mixed  $value) : $this

Adds a param to the list.

This function can be used to add an array of params

Parameters

string $key

Param key

mixed $value

Value to set

Returns

$this

getParam()

getParam(string  $key) : mixed

Returns a specific param.

Parameters

string $key

Key to return

Throws

\Elastica\Exception\InvalidException

If requested key is not set

Returns

mixed —

Key value

hasParam()

hasParam(string  $key) : boolean

Test if a param is set.

Parameters

string $key

Key to test

Returns

boolean —

True if the param is set, false otherwise

getParams()

getParams() : array

Returns the params array.

Returns

array —

Params

count()

count() : integer

{@inheritdoc}

Returns

integer

__construct()

__construct(string  $path, string  $method = self::GET, array  $data = array(), array  $query = array(), \Elastica\Connection  $connection = null, string  $contentType = self::DEFAULT_CONTENT_TYPE) : \Elastica\Request

Construct.

Parameters

string $path

Request path

string $method

OPTIONAL Request method (use const's) (default = self::GET)

array $data

OPTIONAL Data array

array $query

OPTIONAL Query params

\Elastica\Connection $connection
string $contentType

Content-Type sent with this request

Returns

\Elastica\Request

OPTIONAL Connection object

setMethod()

setMethod(string  $method) : $this

Sets the request method. Use one of the for consts.

Parameters

string $method

Request method

Returns

$this

getMethod()

getMethod() : string

Get request method.

Returns

string —

Request method

setData()

setData(array  $data) : $this

Sets the request data.

Parameters

array $data

Request data

Returns

$this

getData()

getData() : array

Return request data.

Returns

array —

Request data

setPath()

setPath(string  $path) : $this

Sets the request path.

Parameters

string $path

Request path

Returns

$this

getPath()

getPath() : string

Return request path.

Returns

string —

Request path

getQuery()

getQuery() : array

Return query params.

Returns

array —

Query params

setQuery()

setQuery(array  $query = array()) : $this

Parameters

array $query

Returns

$this

setConnection()

setConnection(\Elastica\Connection  $connection) : $this

Parameters

\Elastica\Connection $connection

Returns

$this

getConnection()

getConnection() : \Elastica\Connection

Return Connection Object.

Throws

\Elastica\Exception\InvalidException

If no valid connection was setted

Returns

\Elastica\Connection

setContentType()

setContentType(string  $contentType) 

Set the Content-Type of this request.

Parameters

string $contentType

getContentType()

getContentType() 

Get the Content-Type of this request.

send()

send() : \Elastica\Response

Sends request to server.

Returns

\Elastica\Response

Response object

toString()

toString() : string

Converts request to curl request format.

Returns

string

__toString()

__toString() : string

Returns

string

_convertArrayable()

_convertArrayable(array  $array) : array

Cast objects to arrays.

Parameters

array $array

Returns

array

_getBaseName()

_getBaseName() : string

Param's name Picks the last part of the class name and makes it snake_case You can override this method if you want to change the name.

Returns

string —

name

_setRawParam()

_setRawParam(string  $key, mixed  $value) : $this

Sets params not inside params array.

Parameters

string $key
mixed $value

Returns

$this