Class SaveOperation
The "save" operation is used to create or update a record.
-
ICanBoogie\Operation
-
ICanBoogie\Module\Operation\SaveOperation
Methods summary
protected
array
|
#
get_controls( )
Change controls:
- CONTROL_PERMISSION: Module::PERMISSION_CREATE
- CONTROL_OWNERSHIP: true
- CONTROL_FORM: true
Returns
array
|
protected
array
|
#
lazy_get_properties( )
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.
Note:: The getter should only be called during the ICanBoogie\Module\Operation\SaveOperation::process() method.
Returns
array The properties of the operation.
|
protected
|
#
lazy_get_record( )
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( )
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
boolean
|
#
validate( ICanBoogie\ErrorCollection $errors )
The method simply returns true.
The method simply returns true.
Parameters
Returns
boolean
|
protected
array
|
#
process( )
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.
|
protected
ICanBoogie\ActiveRecord
|
#
update_record( array $properties )
Update the operation record with properties.
Update the operation record with properties.
Parameters
Returns
ICanBoogie\ActiveRecord
|
protected
ICanBoogie\ActiveRecord
|
#
create_record( array $properties )
Creates a record from properties.
Creates a record from properties.
Parameters
Returns
ICanBoogie\ActiveRecord
|