BasicSaveAction
class BasicSaveAction extends AbstractSaveAction
Create or update one or more records.
If creating more than one record with similar values, use the "defaults" param.
Set "reload" if you need the api to return complete records.
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 | $records | Array of records. | from AbstractSaveAction |
protected array | $defaults | Array of default values. | from AbstractSaveAction |
protected bool | $reload | Reload records after saving. | from AbstractSaveAction |
Methods
Basic Create constructor.
Magic function to provide addFoo, getFoo and setFoo for params.
Get documentation for one or all params
Validates required fields for actions which create a new object.
This function is used internally for evaluating field annotations.
This Basic Save class can be used in one of two ways:
Details
at line 68
__construct(string $entityName, string $actionName, string $idField = 'id', callable $setter = NULL)
Basic Create constructor.
in AbstractAction at line 149
__set($name, $value)
Strictly enforce api parameters
in AbstractAction at line 158
$this
setVersion(int $val)
in AbstractAction at line 174
$this
addChain(string $name, AbstractAction $apiRequest, string|int $index = NULL)
in AbstractAction at line 187
AbstractAction|mixed
__call($name, $arguments)
Magic function to provide addFoo, getFoo and setFoo for params.
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.
at line 79
_run(Result $result)
We pass the writeRecord function an array representing one item to write.
We expect to get the same format back.
in AbstractAction at line 247
array
getParams()
Serialize this object's params into an array
in AbstractAction at line 265
array
getParamInfo(string $param = NULL)
Get documentation for one or all params
in AbstractAction at line 282
string
getEntityName()
in AbstractAction at line 290
string
getActionName()
in AbstractAction at line 298
bool
paramExists(string $param)
in AbstractAction at line 305
protected array
getParamDefaults()
in AbstractAction at line 312
offsetExists($offset)
in AbstractAction at line 319
offsetGet($offset)
in AbstractAction at line 344
offsetSet($offset, $value)
in AbstractAction at line 359
offsetUnset($offset)
in AbstractAction at line 373
bool
isAuthorized()
Is this api call permitted?
This function is called if checkPermissions is set to true.
in AbstractAction at line 381
array
getPermissions()
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.
in AbstractAction at line 429
ReflectionClass
reflect()
in AbstractAction at line 443
protected array
checkRequiredFields($values)
Validates required fields for actions which create a new object.
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.
in AbstractAction at line 50
bool
getCheckPermissions()
in AbstractAction at line 50
array
getChain()
in AbstractSaveAction at line 106
protected
validateValues()
in AbstractSaveAction at line 121
protected string
getIdField()
in AbstractSaveAction at line 54
array
getRecords()
in AbstractSaveAction at line 54
array
getDefaults()
in AbstractSaveAction at line 54
bool
getReload()
at line 107
protected array
writeRecord(array $item)
This Basic Save class can be used in one of two ways:
- Use this class directly by passing a callable ($setter) to the constructor.
- Extend this class and override this function.
Either way, this function should return an array representing the one new object.