PersistenceMapper Interface Reference

Detailed Description

PersistenceMapper defines the interface for all mapper classes.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 26 of file PersistenceMapper.php.

+ Inheritance diagram for PersistenceMapper:

Public Member Functions

 getType ()
 
 getTypeDisplayName (Message $message)
 
 getTypeDescription (Message $message)
 
 getPkNames ()
 
 getQuoteIdentifierSymbol ()
 
 quoteIdentifier ($identifier)
 
 quoteValue ($value)
 
 getRelations ($hierarchyType='all')
 
 hasRelation ($roleName)
 
 getRelation ($roleName)
 
 getRelationsByType ($type)
 
 getAttributes (array $tags=[], $matchMode='all')
 
 hasAttribute ($name)
 
 getAttribute ($name)
 
 getAttributeDisplayName ($name, Message $message)
 
 getAttributeDescription ($name, Message $message)
 
 getProperties ()
 
 isSortable ($roleName=null)
 
 getSortkey ($roleName=null)
 
 getDefaultOrder ($roleName=null)
 
 load (ObjectId $oid, $buildDepth=BuildDepth::SINGLE)
 
 create ($type, $buildDepth=BuildDepth::SINGLE)
 
 save (PersistentObject $object)
 
 delete (PersistentObject $object)
 
 getOIDs ($type, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
 
 loadObjects ($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
 
 loadRelation (array $objects, $role, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
 
 executeOperation (PersistenceOperation $operation)
 
 beginTransaction ()
 
 commitTransaction ()
 
 rollbackTransaction ()
 

Member Function Documentation

getType ( )

Get the entity type that this mapper handles.

Returns
String

Implemented in NullMapper.

getTypeDisplayName ( Message  $message)

Get the display name of the type.

Parameters
$messageMessage instance used for translation

Implemented in NullMapper.

getTypeDescription ( Message  $message)

Get the description of the type.

Parameters
$messageMessage instance used for translation

Implemented in NullMapper.

getPkNames ( )

Get the names of the primary key values.

Returns
Array with the value names.

Implemented in NullMapper.

getQuoteIdentifierSymbol ( )

Get the symbol used to quote identifiers.

Returns
String

Implemented in RDBMapper, and NullMapper.

quoteIdentifier (   $identifier)

Add quotation to a given identifier (like column name).

Parameters
$identifierThe identifier string
Returns
String

Implemented in RDBMapper, and NullMapper.

quoteValue (   $value)

Add quotation to a given value.

Parameters
$valueThe value
Returns
String

Implemented in RDBMapper, and NullMapper.

getRelations (   $hierarchyType = 'all')

Get the relations for this type.

Parameters
$hierarchyTypeThe hierarchy type that the other type has in relation to this type 'parent', 'child', 'undefined' or 'all' to get all relations (default: 'all')
Returns
Array of RelationDescription instances

Implemented in RDBMapper, and NullMapper.

hasRelation (   $roleName)

Check if a named relation is defined.

Parameters
$roleNameThe role name of the relation
Returns
Boolean

Implemented in NullMapper, and AbstractMapper.

getRelation (   $roleName)

Get the definition for a relation.

Parameters
$roleNameThe role name of the relation
Returns
RelationDescription or null if the relation does not exist

Implemented in RDBMapper, and NullMapper.

getRelationsByType (   $type)

Get the definitions for relations to a given type.

Parameters
$typeThe type name
Returns
Array of RelationDescription instances

Implemented in RDBMapper, and NullMapper.

getAttributes ( array  $tags = [],
  $matchMode = 'all' 
)

PersistentObject values may be tagged with application specific tags.

This method gets the attributes belonging to the given tags.

Parameters
$tagsAn array of tags that the attribute should match. Empty array means all attributes independent of the given matchMode (default: empty array)
$matchModeOne of 'all', 'none', 'any', defines how the attribute's tags should match the given tags (default: 'all')
Returns
Array of AttributeDescription instances

Implemented in RDBMapper, and NullMapper.

hasAttribute (   $name)

Check if a named attribute is defined.

Parameters
$nameThe attribute name
Returns
Boolean

Implemented in NullMapper, and AbstractMapper.

getAttribute (   $name)

Get the definition for an attribute.

Parameters
$nameThe attribute name
Returns
AttributeDescription or null if the attribute does not exist

Implemented in RDBMapper, and NullMapper.

getAttributeDisplayName (   $name,
Message  $message 
)

Get the display name of the type.

Parameters
$nameThe attribute name
$messageMessage instance used for translation

Implemented in NullMapper.

getAttributeDescription (   $name,
Message  $message 
)

Get the description of the attribute.

Parameters
$nameThe attribute name
$messageMessage instance used for translation

Implemented in NullMapper.

getProperties ( )

Get meta information on the mapped class.

Returns
Associative array of key value pairs

Implemented in NullMapper.

isSortable (   $roleName = null)

Check if this type may be explicitly sorted by the user using a persistent attribute which stores the order.

The roleName parameter allows to ask for the order with respect to a specific role.

Parameters
$roleNameThe role name of the relation (optional, default: null)
Returns
Boolean

Implemented in RDBMapper, and NullMapper.

getSortkey (   $roleName = null)

Get the persistent attribute that is used to store the order of the type as explicitly defined by the user.

The roleName parameter allows to ask for the order with respect to a specific role.

Parameters
$roleNameThe role name of the relation (optional, default: null)
Returns
Assciative array with the keys sortType, sortFieldName, sortDirection (ASC or DESC) and isSortkey (Boolean) or null, if the type is not sortable

Implemented in RDBMapper, and NullMapper.

getDefaultOrder (   $roleName = null)

Get the names of the type and attributes to order by default and the sort directions (ASC or DESC).

If the order may be established explicitly by the user, the isSortkey value is true. The roleName parameter allows to ask for the order with respect to a specific role. In a many to many relation the attributes may not be contained in the mapped type, so sortType may be different from the mapper type.

Parameters
$roleNameThe role name of the relation (optional, default: null)
Returns
An array of assciative arrays with the keys sortType, sortFieldName, sortDirection (ASC or DESC) and isSortkey (Boolean)

Implemented in RDBMapper, and NullMapper.

load ( ObjectId  $oid,
  $buildDepth = BuildDepth::SINGLE 
)

Load a PersistentObject instance from the storage.

Note
PersistentMapper implementations must call the PersistentObject::afterLoad() lifecycle callcack on each loaded object and attach it to the current transaction using the Transaction::attach() method.
Parameters
$oidThe object id of the object to construct
$buildDepthOne of the BUILDDEPTH constants or a number describing the number of generations to build (except BuildDepth::REQUIRED, BuildDepth::PROXIES_ONLY) (default: BuildDepth::SINGLE)
Returns
PersistentObject, null if oid does not exist or a given condition prevents loading.

Implemented in NullMapper, and AbstractMapper.

create (   $type,
  $buildDepth = BuildDepth::SINGLE 
)

Construct a PersistentObject instance of a given type.

Note
PersistentMapper implementations must call the PersistentObject::afterCreate() lifecycle callcack on each created object.
Parameters
$typeThe type of object to build
$buildDepthOne of the BUILDDEPTH constants or a number describing the number of generations to build (except BuildDepth::INFINITE, BuildDepth::PROXIES_ONLY) (default: BuildDepth::SINGLE)
Returns
PersistentObject

Implemented in NullMapper, and AbstractMapper.

save ( PersistentObject  $object)

Save a PersistentObject instance.

Note
PersistentMapper implementations must call the PersistentObject::beforeUpdate()/ PersistentObject::afterUpdate() or PersistentObject::beforeInsert()/ PersistentObject::afterInsert() lifecycle callcacks on each object depending on it's state.
Parameters
$objectPersistentObject

Implemented in NullMapper, and AbstractMapper.

delete ( PersistentObject  $object)

Delete a PersistentObject instance.

Note
PersistentMapper implementations must call the PersistentObject::beforeDelete()/ PersistentObject::afterDelete() lifecycle callcacks on each object.
Parameters
$objectPersistentObject

Implemented in AbstractMapper, and NullMapper.

getOIDs (   $type,
  $criteria = null,
  $orderby = null,
PagingInfo  $pagingInfo = null 
)
loadObjects (   $type,
  $buildDepth = BuildDepth::SINGLE,
  $criteria = null,
  $orderby = null,
PagingInfo  $pagingInfo = null 
)
loadRelation ( array  $objects,
  $role,
  $buildDepth = BuildDepth::SINGLE,
  $criteria = null,
  $orderby = null,
PagingInfo  $pagingInfo = null 
)

Load the objects for the specified role.

The implementation must check the navigability of the relation and return null, if the requested direction is not navigable. The result depends on the multiplicity of the relation (singlevalued or multivalued).

Parameters
$objectsArray of PersistentObject or PersstentObjectProxy instances for which the related objects are loaded
$roleThe role of the objects in relation to the given objects
$buildDepthOne of the BUILDDEPTH constants or a number describing the number of generations to build (except BuildDepth::REQUIRED, BuildDepth::PROXIES_ONLY) (default: BuildDepth::SINGLE)
$criteriaAn array of Criteria instances that define conditions on the object's attributes (optional, default: null)
$orderbyAn array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (optional, default: null)
$pagingInfoA reference PagingInfo instance (optional, default: null)
Returns
Associative array with the object ids of the origin objects as keys and arrays of related PersistentObject instances as values or null, if not navigable

Implemented in AbstractMapper, and NullMapper.

executeOperation ( PersistenceOperation  $operation)

Execute a PersistenceOperation.

PersistenceOperation.type must be the type that is mapped by this mapper.

Parameters
$operationThe operation
Returns
int The number of affected rows.

Implemented in RDBMapper, and NullMapper.

beginTransaction ( )

Start a transaction on the transactional resource (e.g.

database) of this mapper. Nested transactions are not supported, so the implementation should ignore consecutive calls, if a transaction is already started.

Implemented in RDBMapper, and NullMapper.

commitTransaction ( )

Commit the transaction on the transactional resource (e.g.

database) of this mapper. The implementation should ignore calls, if no transaction is started yet.

Implemented in RDBMapper, and NullMapper.

rollbackTransaction ( )

Rollback the transaction on the transactional resource (e.g.

database) of this mapper. The implementation should ignore calls, if no transaction is started yet.

Implemented in RDBMapper, and NullMapper.