Class SaveOperation
The "save" operation is used to create or update a record.
-
ICanBoogie\Operation
-
┗
ICanBoogie\SaveOperation
Namespace: ICanBoogie
Located at operations/save.php
Methods summary
protected
get_controls( void )
: array
Change controls:
- CONTROL_PERMISSION: Module::PERMISSION_CREATE
- CONTROL_OWNERSHIP: true
- CONTROL_FORM: true
Returns
array
protected
lazy_get_record( void )
Overrides the getter to prevent exceptions when the operation key is empty.
Overrides the getter to prevent exceptions when the operation key is empty.
protected
control_record( void )
Overrides the method in order for the control to pass if the operation key is empty, which
is the case when creating a new record.
Overrides the method in order for the control to pass if the operation key is empty, which
is the case when creating a new record.
protected
lazy_get_properties( void )
: array
Filters out the operation's parameters, which are not defined as fields by the
primary model of the module, and take care of filtering or resolving properties values.
Filters out the operation's parameters, which are not defined as fields by the
primary model of the module, and take care of filtering or resolving properties values.
Fields defined as 'boolean'
The value of the property is filtered using the filter_var() function and the
FILTER_VALIDATE_BOOLEAN filter. If the property in the operation params is empty, the
property value is set the false
.
Fields defined as 'varchar'
If the property is not empty in the operation params, the property value is trimmed using the
trim() function, ensuring that there is no leading or trailing white spaces.
Returns
array
The properties of the operation.
protected
validate( ICanBoogie\Errors $errors
)
: boolean
The method simply returns true.
The method simply returns true.
Parameters
Returns
boolean
protected
process( void )
: array
Creates or updates a record in the module's primary model.
Creates or updates a record in the module's primary model.
A record is created if the operation's key is empty, otherwise an existing record is
updated.
The method uses the properties
property to get the properties used to create or update
the record.
Returns
array
An array composed of the save mode ('update' or 'new') and the record's
key.
Throws
RuntimeException
when saving the record fails.