Datamanager 2 Data storage base class.

It implements the basic interface required for data storage operations. Naturally, only the construction of storage backends is suspect to class specific code, the actual operation should be completely transparent across all storage implementations.

See the individual subclasses for details about their operation.

package midcom.helper.datamanager2

 Methods

__construct (\midcom_helper_datamanager2_schema $schema)

Creates the storage interface class, and initializes it to a given data schema.

Specific storage implementation subclasses will need to expand this constructor to take care of linking to the right storage object, where applicable.

Parameters

$schema

\midcom_helper_datamanager2_schema&$schema The data schema to use for processing.

_on_load_data (string $name)

Implement the storage method for your backend here.

It has to store the given data to the schema field identified by the given name.

Parameters

$name

stringThe name of the field to load from.

Returns

mixed$data The data which has been loaded.

_on_store_data (string $name, mixed $data)

Implement the storage method for your backend here.

It has to store the given data to the schema field identified by the given name.

Parameters

$name

stringThe name of the field to save to.

$data

mixedThe data to save to.

_on_update_object ()

This callback is invoked once the storage object has been completely updated with the information from all types.

You need to store it to the database at this point.

Returns

booleanIndicating success.

can_do (string $privilege)

Checks whether the current user has the given privilege on the storage backend.

If there is no valid storage backend, a can_user_do is performed. Subclasses may overwrite this method to incorporate for creation mode stuff.

Parameters

$privilege

stringThe privilege to check against.

Returns

booleantrue if the user has the permission, false otherwise.

create_temporary_object ()

This function will populate the $object member with a temporary object obtained by the MidCOM temporary object service.

The code using this storage instance must take care of transitting this temporary object into future sessions (which means switching to another storage backend at that point).

If the storage object is already populated, the method will exit silently.

see \midcom_services_tmp
see \midcom_core_temporary_object

load (array $types)

Loads a set of types to the configured storage object.

This is done by subclass implementations, where this function serves as a request switch.

Any types defined in the schema but not found in the passed type listing are ignored unless they are flagged as required, in which case midcom_error is thrown.

Parameters

$types

array&$types A reference to an array of types matching the schema definition.

store (array $types)

Stores a set of types to the configured storage object.

This is done by subclass implementations, where this function serves as a request switch.

Any types defined in the schema but not found in the passed type listing are ignored unless they are flagged as required, in which case midcom_error is called.

Parameters

$types

array&$types A reference to an array of types matching the schema definition.

Returns

booleanIndicating success.

 Properties

 

\midcom_helper_datamanager2_schema $_schema

A reference to the data schema used for processing.
access protected
 

\MidCOMDBAObject $object

This is a reference the storage object used by the subclass implementation.

Types may use this reference only for attachment operations and parameter operations related to attachment operations.

It can be safely considered that a MidCOM DBA object is available here if the reference is non-null.

Since this member is not necessarily populated in all cases, the base API provides callers with a create_temporary_object helper function: It will put a temporary object into $object, so that attachment operations can still be done. The storage object user must take care of the information stored on that object.