ICanBoogie
  • Documentation
  • API Reference
  • Module 4.0.x
Namespaces
  • ICanBoogie
    • Module
      • ModuleCollection
      • Operation
Classes
  • DeleteOperation
  • SaveOperation

Class SaveOperation

The "save" operation is used to create or update a record.

ICanBoogie\Operation
┗ ICanBoogie\Module\Operation\SaveOperation
Namespace: ICanBoogie\Module\Operation
Located at Module/Operation/SaveOperation.php

Methods summary

protected get_controls( void ) : array

Change controls:

Change controls:

  • CONTROL_PERMISSION: Module::PERMISSION_CREATE
  • CONTROL_OWNERSHIP: true
  • CONTROL_FORM: true

Returns

array
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.

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( 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 validate( ICanBoogie\ErrorCollection $errors ) : boolean

The method simply returns true.

The method simply returns true.

Parameters

$errors

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.
protected update_record( array $properties ) : ICanBoogie\ActiveRecord

Update the operation record with properties.

Update the operation record with properties.

Parameters

$properties

Returns

ICanBoogie\ActiveRecord
protected create_record( array $properties ) : ICanBoogie\ActiveRecord

Creates a record from properties.

Creates a record from properties.

Parameters

$properties

Returns

ICanBoogie\ActiveRecord

Properties summary

Magic properties

public $properties : array

The properties to save.

Module 4.0.x – Check on GitHub – API documentation generated by ApiGen