class DAODeleteAction extends AbstractBatchAction

Delete one or more items, based on criteria specified in Where param (required).

Traits

Properties

protected int $version Api version number; cannot be changed. from AbstractAction
protected array $chain Additional api requests - will be called once per result. from AbstractAction
protected bool $checkPermissions Whether to enforce acl permissions based on the current user. from AbstractAction
protected string $_entityName from AbstractAction
protected string $_actionName from AbstractAction
protected array $where Criteria for selecting items to process. from AbstractBatchAction
protected array $orderBy Array of field(s) to use in ordering the results from AbstractQueryAction
protected int $limit Maximum number of results to return. from AbstractQueryAction
protected int $offset Zero-based index of first result to return. from AbstractQueryAction
protected string $language Specify the language to use if this is a multi-lingual environment. from DAOActionTrait

Methods

__construct(string $entityName, string $actionName, string|array $select = 'id')

BatchAction constructor.

__set($name, $value)

Strictly enforce api parameters

$this
setVersion(int $val)

No description

$this
addChain(string $name, AbstractAction $apiRequest, string|int $index = NULL)

No description

__call($name, $arguments)

Magic function to provide addFoo, getFoo and setFoo for params.

execute()

Invoke api call.

_run(Result $result)

Batch delete function

array
getParams()

Serialize this object's params into an array

array
getParamInfo(string $param = NULL)

Get documentation for one or all params

string
getEntityName()

No description

string
getActionName()

No description

bool
paramExists(string $param)

No description

array
getParamDefaults()

No description

offsetExists($offset)

No description

offsetGet($offset)

No description

offsetSet($offset, $value)

No description

offsetUnset($offset)

No description

bool
isAuthorized()

Is this api call permitted?

array
getPermissions()

No description

array
entityFields()

Returns schema fields for this entity & action.

reflect()

No description

array
checkRequiredFields($values)

Validates required fields for actions which create a new object.

bool
evaluateCondition(string $expr, array $vars)

This function is used internally for evaluating field annotations.

bool
getCheckPermissions()

No description

array
getChain()

No description

$this
addWhere(string $field, string $op, mixed $value = NULL)

No description

$this
addClause(string $operator, mixed $condition1)

Adds one or more AND/OR/NOT clause groups

$this
addOrderBy(string $field, string $direction = 'ASC')

No description

string
whereClauseToString(array $whereClause = NULL, string $op = 'AND')

A human-readable where clause, for the reading enjoyment of you humans.

array
getWhere()

No description

array
getOrderBy()

No description

int
getLimit()

No description

int
getOffset()

No description

array
getBatchRecords()

No description

array
getSelect()

No description

CRM_Core_DAO|string
getBaoName()

No description

static array
baoToArray(object $bao)

Extract the true fields from a BAO

array|int
getObjects()

No description

fillDefaults(array $params)

Fill field defaults which were declared by the api.

array
writeObjects(array $items)

Write bao objects as part of a create/update action.

mixed
formatCustomParams(array $params, int $entityId)

No description

checkContactPermissions($baoName, $item)

Check edit/delete permissions for contacts and related entities.

string
getLanguage()

No description

setLanguage(string $language)

No description

array
deleteObjects($items)

No description

Details

in AbstractBatchAction at line 69
__construct(string $entityName, string $actionName, string|array $select = 'id')

BatchAction constructor.

Parameters

string $entityName
string $actionName
string|array $select One or more fields to load for each item.

in AbstractAction at line 149
__set($name, $value)

Strictly enforce api parameters

Parameters

$name
$value

Exceptions

Exception

in AbstractAction at line 158
$this setVersion(int $val)

Parameters

int $val

Return Value

$this

Exceptions

API_Exception

in AbstractAction at line 174
$this addChain(string $name, AbstractAction $apiRequest, string|int $index = NULL)

Parameters

string $name Unique name for this chained request
AbstractAction $apiRequest
string|int $index Either a string for how the results should be indexed e.g. 'name' or the index of a single result to return e.g. 0 for the first result.

Return Value

$this

in AbstractAction at line 187
AbstractAction|mixed __call($name, $arguments)

Magic function to provide addFoo, getFoo and setFoo for params.

Parameters

$name
$arguments

Return Value

AbstractAction|mixed

Exceptions

API_Exception

in AbstractAction at line 231
Result execute()

Invoke api call.

At this point all the params have been sent in and we initiate the api call & return the result. This is basically the outer wrapper for api v4.

Return Value

Result

Exceptions

UnauthorizedException

at line 49
_run(Result $result)

Batch delete function

Parameters

Result $result

in AbstractAction at line 247
array getParams()

Serialize this object's params into an array

Return Value

array

in AbstractAction at line 265
array getParamInfo(string $param = NULL)

Get documentation for one or all params

Parameters

string $param

Return Value

array of arrays [description, type, default, (comment)]

in AbstractAction at line 282
string getEntityName()

Return Value

string

in AbstractAction at line 290
string getActionName()

Return Value

string

in AbstractAction at line 298
bool paramExists(string $param)

Parameters

string $param

Return Value

bool

in AbstractAction at line 305
protected array getParamDefaults()

Return Value

array

in AbstractAction at line 312
offsetExists($offset)

Parameters

$offset

in AbstractAction at line 319
offsetGet($offset)

Parameters

$offset

in AbstractAction at line 344
offsetSet($offset, $value)

Parameters

$offset
$value

in AbstractAction at line 359
offsetUnset($offset)

Parameters

$offset

in AbstractAction at line 373
bool isAuthorized()

Is this api call permitted?

This function is called if checkPermissions is set to true.

Return Value

bool

in AbstractAction at line 381
array getPermissions()

Return Value

array

in AbstractAction at line 410
array entityFields()

Returns schema fields for this entity & action.

Here we bypass the api wrapper and execute the getFields action directly. This is because we DON'T want the wrapper to check permissions as this is an internal op, but we DO want permissions to be checked inside the getFields request so e.g. the api_key field can be conditionally included.

Return Value

array

See also

GetFields

in AbstractAction at line 429
ReflectionClass reflect()

Return Value

ReflectionClass

in AbstractAction at line 443
protected array checkRequiredFields($values)

Validates required fields for actions which create a new object.

Parameters

$values

Return Value

array

Exceptions

API_Exception

in AbstractAction at line 473
protected bool evaluateCondition(string $expr, array $vars)

This function is used internally for evaluating field annotations.

It should never be passed raw user input.

Parameters

string $expr Conditional in php format e.g. $foo > $bar
array $vars Variable name => value

Return Value

bool

Exceptions

API_Exception
Exception

in AbstractAction at line 50
bool getCheckPermissions()

Return Value

bool

in AbstractAction at line 50
array getChain()

Return Value

array

in AbstractQueryAction at line 104
$this addWhere(string $field, string $op, mixed $value = NULL)

Parameters

string $field
string $op
mixed $value

Return Value

$this

Exceptions

API_Exception

in AbstractQueryAction at line 122
$this addClause(string $operator, mixed $condition1)

Adds one or more AND/OR/NOT clause groups

Parameters

string $operator
mixed $condition1 ... $conditionN Either a nested array of arguments, or a variable number of arguments passed to this function.

Return Value

$this

Exceptions

API_Exception

in AbstractQueryAction at line 135
$this addOrderBy(string $field, string $direction = 'ASC')

Parameters

string $field
string $direction

Return Value

$this

in AbstractQueryAction at line 147
protected string whereClauseToString(array $whereClause = NULL, string $op = 'AND')

A human-readable where clause, for the reading enjoyment of you humans.

Parameters

array $whereClause
string $op

Return Value

string

in AbstractQueryAction at line 54
array getWhere()

Return Value

array

in AbstractQueryAction at line 54
array getOrderBy()

Return Value

array

in AbstractQueryAction at line 54
int getLimit()

Return Value

int

in AbstractQueryAction at line 54
int getOffset()

Return Value

int

in AbstractBatchAction at line 77
protected array getBatchRecords()

Return Value

array

in AbstractBatchAction at line 95
protected array getSelect()

Return Value

array

in DAOActionTrait at line 61
protected CRM_Core_DAO|string getBaoName()

Return Value

CRM_Core_DAO|string

in DAOActionTrait at line 73
static array baoToArray(object $bao)

Extract the true fields from a BAO

(Used by create and update actions)

Parameters

object $bao

Return Value

array

in DAOActionTrait at line 88
protected array|int getObjects()

Return Value

array|int

in DAOActionTrait at line 109
protected fillDefaults(array $params)

Fill field defaults which were declared by the api.

Note: default values from core are ignored because the BAO or database layer will supply them.

Parameters

array $params

in DAOActionTrait at line 131
protected array writeObjects(array $items)

Write bao objects as part of a create/update action.

Parameters

array $items The records to write to the DB.

Return Value

array The records after being written to the DB (e.g. including newly assigned "id").

Exceptions

API_Exception

in DAOActionTrait at line 214
protected mixed formatCustomParams(array $params, int $entityId)

Parameters

array $params
int $entityId

Return Value

mixed

in DAOActionTrait at line 280
protected checkContactPermissions($baoName, $item)

Check edit/delete permissions for contacts and related entities.

Parameters

$baoName
$item

Exceptions

UnauthorizedException

in DAOActionTrait at line 47
string getLanguage()

Return Value

string

in DAOActionTrait at line 47
setLanguage(string $language)

Parameters

string $language

at line 71
protected array deleteObjects($items)

Parameters

$items

Return Value

array

Exceptions

API_Exception