ExportAction
extends AbstractAction
in package
Export $ENTITY to civicrm_managed format.
This action generates an exportable array suitable for use in a .mgd.php file. The array will include any other entities that reference the $ENTITY.
Table of Contents
Properties
- $_debugOutput : mixed
- $_actionName : string
- $_entityName : string
- $chain : array<string|int, mixed>
- Additional api requests - will be called once per result.
- $checkPermissions : bool
- Whether to enforce acl permissions based on the current user.
- $cleanup : string
- Specify rule for auto-deleting managed entity
- $debug : bool
- Add debugging info to the api result.
- $id : int
- Id of $ENTITY to export
- $language : string
- Preferred language (optional)
- $match : array<string|int, mixed>
- Fields to match when managed records are being reconciled.
- $update : string
- Specify rule for auto-updating managed entity
- $version : int
- Api version number; cannot be changed.
- $_arrayStorage : array<string|int, mixed>
- $_entityFields : array<string|int, mixed>
- $_id : int
- $_paramInfo : array<string|int, mixed>
- $_reflection : ReflectionClass
- $exportedEntities : array<string|int, mixed>
- Used to prevent circular references
Methods
- __call() : static|mixed
- Magic function to provide automatic getter/setter for params.
- __construct() : mixed
- Action constructor.
- __set() : mixed
- Strictly enforce api parameters
- _run() : mixed
- addChain() : $this
- entityFields() : array<string|int, mixed>
- Returns schema fields for this entity & action.
- evaluateCondition() : bool
- This function is used internally for evaluating field annotations.
- execute() : Result
- Invoke api call.
- getActionName() : string
- getChain() : array<string|int, mixed>
- getCheckPermissions() : bool
- getCleanup() : string
- getDebug() : bool
- getEntityName() : string
- getId() : int
- getLanguage() : string|null
- getMatch() : array<string|int, mixed>
- getParamInfo() : array<string|int, mixed>
- Get documentation for one or all params
- getParams() : array<string|int, mixed>
- Serialize this object's params into an array
- getPermissions() : array<string|int, mixed>
- getUpdate() : string
- offsetExists() : bool
- offsetGet() : mixed
- offsetSet() : void
- offsetUnset() : void
- paramExists() : bool
- reflect() : ReflectionClass
- setChain() : $this
- setCheckPermissions() : $this
- setCleanup() : $this
- setDebug() : $this
- setId() : $this
- setLanguage() : $this
- setMatch() : $this
- setUpdate() : $this
- setVersion() : $this
- addCallbackToDebugOutput() : mixed
- When in debug mode, this logs the callback function being used by a Basic*Action class.
- checkRequiredFields() : array<string|int, mixed>
- Validates required fields for actions which create a new object.
- formatWriteValues() : mixed
- Replaces pseudoconstants in input values
- getLanguageOptions() : array<string|int, mixed>
- Get available preferred languages.
- getMagicProperties() : array<string|int, mixed>
- Get a list of class properties for which magic methods are supported.
- getMatchFields() : array<string|int, mixed>
- Options callback for $this->match
- getParamDefaults() : array<string|int, mixed>
- exportRecord() : mixed
- getFieldsForExport() : array<string|int, mixed>
- shouldUsePseudoconstant() : bool
- If a field has a pseudoconstant list, determine whether it would be better to use pseudoconstant (field:name) syntax vs plain value.
Properties
$_debugOutput
public
mixed
$_debugOutput
= []
$_actionName
protected
string
$_actionName
$_entityName
protected
string
$_entityName
$chain
Additional api requests - will be called once per result.
protected
array<string|int, mixed>
$chain
= []
Keys can be any string - this will be the name given to the output.
You can reference other values in the api results in this call by prefixing them with $
.
For example, you could create a contact and place them in a group by chaining the
GroupContact
api to the Contact
api:
Contact::create()
->setValue('first_name', 'Hello')
->addChain('add_a_group', GroupContact::create()
->setValue('contact_id', '$id')
->setValue('group_id', 123)
)
This will substitute the id of the newly created contact with $id
.
$checkPermissions
Whether to enforce acl permissions based on the current user.
protected
bool
$checkPermissions
= TRUE
Setting to FALSE will disable permission checks and override ACLs. In REST/javascript this cannot be disabled.
$cleanup
Specify rule for auto-deleting managed entity
protected
string
$cleanup
= 'unused'
Tags
$debug
Add debugging info to the api result.
protected
bool
$debug
= FALSE
When enabled, $result->debug
will be populated with information about the api call,
including sql queries executed.
Note: with checkPermissions enabled, debug info will only be returned if the user has "view debug output" permission.
$id
Id of $ENTITY to export
protected
int
$id
Tags
$language
Preferred language (optional)
protected
string
$language
This option will notify major localization subsystems (ts()
, multilingual, etc)
about which locale should be used for composing/formatting messaging.
This indicates the preferred language. The effective language is determined
by Civi\Core\Locale::negotiate($preferredLanguage)
.
Tags
$match
Fields to match when managed records are being reconciled.
protected
array<string|int, mixed>
$match
By default this will be set automatically based on the entity's unique fields.
Tags
$update
Specify rule for auto-updating managed entity
protected
string
$update
= 'unmodified'
Tags
$version
Api version number; cannot be changed.
protected
int
$version
= 4
$_arrayStorage
private
array<string|int, mixed>
$_arrayStorage
= []
$_entityFields
private
array<string|int, mixed>
$_entityFields
$_id
private
int
$_id
Used to identify api calls for transactions
Tags
$_paramInfo
private
array<string|int, mixed>
$_paramInfo
$_reflection
private
ReflectionClass
$_reflection
$exportedEntities
Used to prevent circular references
private
array<string|int, mixed>
$exportedEntities
= []
Methods
__call()
Magic function to provide automatic getter/setter for params.
public
__call(mixed $name, mixed $arguments) : static|mixed
Parameters
- $name : mixed
- $arguments : mixed
Tags
Return values
static|mixed__construct()
Action constructor.
public
__construct(string $entityName, string $actionName) : mixed
Parameters
- $entityName : string
- $actionName : string
__set()
Strictly enforce api parameters
public
__set(mixed $name, mixed $value) : mixed
Parameters
- $name : mixed
- $value : mixed
Tags
_run()
public
_run(Result $result) : mixed
Parameters
- $result : Result
addChain()
public
addChain(string $name, AbstractAction $apiRequest[, string|int|array<string|int, mixed> $index = NULL ]) : $this
Parameters
- $name : string
-
Unique name for this chained request
- $apiRequest : AbstractAction
- $index : string|int|array<string|int, mixed> = NULL
-
See
civicrm_api4()
for documentation of$index
param
Return values
$thisentityFields()
Returns schema fields for this entity & action.
public
entityFields() : array<string|int, mixed>
Here we bypass the api wrapper and run the getFields action directly. This is because we DON'T want the wrapper to check permissions as this is an internal op.
Tags
Return values
array<string|int, mixed>evaluateCondition()
This function is used internally for evaluating field annotations.
public
static evaluateCondition(string $expr, array<string|int, mixed> $vars) : bool
It should never be passed raw user input.
Parameters
- $expr : string
-
Conditional in php format e.g. $foo > $bar
- $vars : array<string|int, mixed>
-
Variable name => value
Tags
Return values
boolexecute()
Invoke api call.
public
execute() : Result
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.
Tags
Return values
ResultgetActionName()
public
getActionName() : string
Return values
stringgetChain()
public
getChain() : array<string|int, mixed>
Return values
array<string|int, mixed>getCheckPermissions()
public
getCheckPermissions() : bool
Return values
boolgetCleanup()
public
getCleanup() : string
Return values
stringgetDebug()
public
getDebug() : bool
Return values
boolgetEntityName()
public
getEntityName() : string
Return values
stringgetId()
public
getId() : int
Return values
intgetLanguage()
public
getLanguage() : string|null
Return values
string|nullgetMatch()
public
getMatch() : array<string|int, mixed>
Return values
array<string|int, mixed>getParamInfo()
Get documentation for one or all params
public
getParamInfo([string $param = NULL ]) : array<string|int, mixed>
Parameters
- $param : string = NULL
Return values
array<string|int, mixed> —of arrays [description, type, default, (comment)]
getParams()
Serialize this object's params into an array
public
getParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getPermissions()
public
getPermissions() : array<string|int, mixed>
Return values
array<string|int, mixed>getUpdate()
public
getUpdate() : string
Return values
stringoffsetExists()
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Tags
Return values
booloffsetGet()
public
& offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Tags
offsetUnset()
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Tags
paramExists()
public
paramExists(string $param) : bool
Parameters
- $param : string
Return values
boolreflect()
public
reflect() : ReflectionClass
Return values
ReflectionClasssetChain()
public
setChain([array<string|int, mixed> $chain = ]) : $this
Parameters
- $chain : array<string|int, mixed> =
Return values
$thissetCheckPermissions()
public
setCheckPermissions(bool $checkPermissions) : $this
Parameters
- $checkPermissions : bool
Return values
$thissetCleanup()
public
setCleanup([string $cleanup = ]) : $this
Parameters
- $cleanup : string =
Return values
$thissetDebug()
public
setDebug([bool $debug = ]) : $this
Enable/disable debug output
Parameters
- $debug : bool =
Return values
$thissetId()
public
setId([int $id = ]) : $this
Parameters
- $id : int =
Return values
$thissetLanguage()
public
setLanguage([string|null $language = ]) : $this
Parameters
- $language : string|null =
Return values
$thissetMatch()
public
setMatch([array<string|int, mixed> $match = ]) : $this
Specify fields to match for update.
Parameters
- $match : array<string|int, mixed> =
Return values
$thissetUpdate()
public
setUpdate([string $update = ]) : $this
Parameters
- $update : string =
Return values
$thissetVersion()
public
setVersion(int $val) : $this
Parameters
- $val : int
Tags
Return values
$thisaddCallbackToDebugOutput()
When in debug mode, this logs the callback function being used by a Basic*Action class.
protected
addCallbackToDebugOutput(callable $callable) : mixed
Parameters
- $callable : callable
checkRequiredFields()
Validates required fields for actions which create a new object.
protected
checkRequiredFields(mixed $values) : array<string|int, mixed>
Parameters
- $values : mixed
Tags
Return values
array<string|int, mixed>formatWriteValues()
Replaces pseudoconstants in input values
protected
formatWriteValues(array<string|int, mixed> &$record) : mixed
Parameters
- $record : array<string|int, mixed>
Tags
getLanguageOptions()
Get available preferred languages.
protected
getLanguageOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getMagicProperties()
Get a list of class properties for which magic methods are supported.
protected
static getMagicProperties() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of supported properties, keyed by property name. Array(string $propertyName => bool $true).
getMatchFields()
Options callback for $this->match
protected
getMatchFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getParamDefaults()
protected
getParamDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>exportRecord()
private
exportRecord(string $entityType, int $entityId, Result $result[, string $parentName = NULL ][, array<string|int, mixed> $excludeFields = [] ]) : mixed
Parameters
- $entityType : string
- $entityId : int
- $result : Result
- $parentName : string = NULL
- $excludeFields : array<string|int, mixed> = []
getFieldsForExport()
private
getFieldsForExport(mixed $entityType[, bool $loadOptions = FALSE ][, array<string|int, mixed> $excludeFields = [] ]) : array<string|int, mixed>
Parameters
- $entityType : mixed
- $loadOptions : bool = FALSE
- $excludeFields : array<string|int, mixed> = []
Return values
array<string|int, mixed>shouldUsePseudoconstant()
If a field has a pseudoconstant list, determine whether it would be better to use pseudoconstant (field:name) syntax vs plain value.
private
shouldUsePseudoconstant(string $entityType, array<string|int, mixed> $field) : bool
Parameters
- $entityType : string
- $field : array<string|int, mixed>