MockBasicEntity
extends BasicEntity
in package
MockBasicEntity entity.
Tags
Table of Contents
Properties
- $deleter : callable
- Function to delete records. Used by `delete` action.
- $getter : callable
- Function to read records. Used by `get` action.
- $setter : callable
- Function to write a record. Used by `create`, `update` and `save`.
Methods
- __callStatic() : AbstractAction
- Magic method to return the action object for an api.
- autocomplete() : AutocompleteAction
- batchFrobnicate() : BasicBatchAction
- checkAccess() : CheckAccessAction
- create() : BasicCreateAction
- delete() : BasicBatchAction
- get() : BasicGetAction
- getActions() : GetActions
- getEntityName() : string
- Get entity name from called class
- getFields() : BasicGetFieldsAction
- getInfo() : array{name: string, title: string, description: string, title_plural: string, type: string, paths: array, class: string, primary_key: array, searchable: string, dao: string, label_field: string, icon: string}
- Reflection function called by Entity::get()
- getLinks() : GetLinks
- permissions() : array<string|int, mixed>
- Returns a list of permissions needed to access the various actions in this api.
- replace() : BasicReplaceAction
- save() : BasicSaveAction
- update() : BasicUpdateAction
- getDaoName() : CRM_Core_DAO|string|null
- getEntityTitle() : string
- Overridable function to return a localized title for this entity.
Properties
$deleter
Function to delete records. Used by `delete` action.
protected
static callable
$deleter
= [\Civi\Mock\MockEntityDataStorage::class, 'delete']
Function(array $item, BasicBatchAction $thisAction): array
This function is called once per delete. It takes a single record as the first param, and a reference to the action object as the second.
This callback should check the $idField of the item to determine which record to delete.
It should return the deleted record as an array.
$getter
Function to read records. Used by `get` action.
protected
static callable
$getter
= [\Civi\Mock\MockEntityDataStorage::class, 'get']
Function(BasicGetAction $thisAction): array[]
This function should return an array of records, and is passed a copy of the BasicGetAction object as its first argument. The simplest implementation is for it to return every record and the BasicGetAction automatically handle sorting and filtering.
If performance is a concern, it can take advantage of some helper functions for e.g. fetching item(s) by id.
$setter
Function to write a record. Used by `create`, `update` and `save`.
protected
static callable
$setter
= [\Civi\Mock\MockEntityDataStorage::class, 'write']
Function(array $item, BasicCreateAction|BasicSaveAction|BasicUpdateAction $thisAction): array
This function is called once per write. It takes a single record as the first param, and a reference to the action object as the second.
This callback should check the $idField of the record to determine whether the operation is a create or update.
It should return the updated record as an array.
Methods
__callStatic()
Magic method to return the action object for an api.
public
static __callStatic(string $action, array<string|int, mixed> $args) : AbstractAction
Parameters
- $action : string
- $args : array<string|int, mixed>
Tags
Return values
AbstractActionautocomplete()
public
static autocomplete([bool $checkPermissions = TRUE ]) : AutocompleteAction
Parameters
- $checkPermissions : bool = TRUE
Return values
AutocompleteActionbatchFrobnicate()
public
static batchFrobnicate([bool $checkPermissions = TRUE ]) : BasicBatchAction
Parameters
- $checkPermissions : bool = TRUE
Return values
BasicBatchActioncheckAccess()
public
static checkAccess() : CheckAccessAction
Return values
CheckAccessActioncreate()
public
static create([bool $checkPermissions = TRUE ]) : BasicCreateAction
Parameters
- $checkPermissions : bool = TRUE
Return values
BasicCreateActiondelete()
public
static delete([bool $checkPermissions = TRUE ]) : BasicBatchAction
Parameters
- $checkPermissions : bool = TRUE
Return values
BasicBatchActionget()
public
static get([bool $checkPermissions = TRUE ]) : BasicGetAction
Parameters
- $checkPermissions : bool = TRUE
Return values
BasicGetActiongetActions()
public
static getActions([bool $checkPermissions = TRUE ]) : GetActions
Parameters
- $checkPermissions : bool = TRUE
Return values
GetActionsgetEntityName()
Get entity name from called class
public
static getEntityName() : string
Return values
stringgetFields()
public
static getFields([mixed $checkPermissions = TRUE ]) : BasicGetFieldsAction
Parameters
- $checkPermissions : mixed = TRUE
Tags
Return values
BasicGetFieldsActiongetInfo()
Reflection function called by Entity::get()
public
static getInfo() : array{name: string, title: string, description: string, title_plural: string, type: string, paths: array, class: string, primary_key: array, searchable: string, dao: string, label_field: string, icon: string}
Tags
Return values
array{name: string, title: string, description: string, title_plural: string, type: string, paths: array, class: string, primary_key: array, searchable: string, dao: string, label_field: string, icon: string}getLinks()
public
static getLinks([bool $checkPermissions = TRUE ]) : GetLinks
Parameters
- $checkPermissions : bool = TRUE
Return values
GetLinkspermissions()
Returns a list of permissions needed to access the various actions in this api.
public
static permissions() : array<string|int, mixed>
Return values
array<string|int, mixed>replace()
public
static replace([bool $checkPermissions = TRUE ]) : BasicReplaceAction
Parameters
- $checkPermissions : bool = TRUE
Return values
BasicReplaceActionsave()
public
static save([bool $checkPermissions = TRUE ]) : BasicSaveAction
Parameters
- $checkPermissions : bool = TRUE
Return values
BasicSaveActionupdate()
public
static update([bool $checkPermissions = TRUE ]) : BasicUpdateAction
Parameters
- $checkPermissions : bool = TRUE
Return values
BasicUpdateActiongetDaoName()
protected
static getDaoName() : CRM_Core_DAO|string|null
Return values
CRM_Core_DAO|string|nullgetEntityTitle()
Overridable function to return a localized title for this entity.
protected
static getEntityTitle([bool $plural = FALSE ]) : string
Parameters
- $plural : bool = FALSE
-
Whether to return a plural title.