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 ()
 
 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)
 
 getReferences ()
 
 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 ()
 
 getStatements ()
 

Member Function Documentation

◆ getType()

getType ( )

Get the entity type that this mapper handles.

Returns
String

Implemented in NullMapper.

◆ getTypeDisplayName()

getTypeDisplayName ( Message  $message)

Get the display name of the type.

Parameters
$messageMessage instance used for translation

Implemented in AbstractMapper, and NullMapper.

◆ getTypeDescription()

getTypeDescription ( Message  $message)

Get the description of the type.

Parameters
$messageMessage instance used for translation

Implemented in AbstractMapper, and NullMapper.

◆ getPkNames()

getPkNames ( )

Get the names of the primary key values.

Returns
Array with the value names.

Implemented in NullMapper.

◆ getRelations()

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 AbstractRDBMapper, and NullMapper.

◆ hasRelation()

hasRelation (   $roleName)

Check if a named relation is defined.

Parameters
$roleNameThe role name of the relation
Returns
Boolean

Implemented in AbstractMapper, and NullMapper.

◆ getRelation()

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 AbstractMapper, and NullMapper.

◆ getRelationsByType()

getRelationsByType (   $type)

Get the definitions for relations to a given type.

Parameters
$typeThe type name
Returns
Array of RelationDescription instances

Implemented in AbstractMapper, and NullMapper.

◆ getAttributes()

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 AbstractRDBMapper, and NullMapper.

◆ hasAttribute()

hasAttribute (   $name)

Check if a named attribute is defined.

Parameters
$nameThe attribute name
Returns
Boolean

Implemented in AbstractMapper, and NullMapper.

◆ getAttribute()

getAttribute (   $name)

Get the definition for an attribute.

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

Implemented in AbstractMapper, and NullMapper.

◆ getAttributeDisplayName()

getAttributeDisplayName (   $name,
Message  $message 
)

Get the display name of the type.

Parameters
$nameThe attribute name
$messageMessage instance used for translation

Implemented in AbstractMapper, and NullMapper.

◆ getAttributeDescription()

getAttributeDescription (   $name,
Message  $message 
)

Get the description of the attribute.

Parameters
$nameThe attribute name
$messageMessage instance used for translation

Implemented in AbstractMapper, and NullMapper.

◆ getReferences()

getReferences ( )

Get the references to other entities.

Returns
Array of ReferenceDescription instances

Implemented in AbstractMapper, and NullMapper.

◆ getProperties()

getProperties ( )

Get meta information on the mapped class.

Returns
Associative array of key value pairs

Implemented in AbstractMapper, and NullMapper.

◆ isSortable()

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 AbstractRDBMapper, and NullMapper.

◆ getSortkey()

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 AbstractRDBMapper, and NullMapper.

◆ getDefaultOrder()

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 AbstractRDBMapper, and NullMapper.

◆ load()

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 AbstractMapper, and NullMapper.

◆ create()

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 AbstractMapper, and NullMapper.

◆ save()

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 AbstractMapper, and NullMapper.

◆ delete()

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()

getOIDs (   $type,
  $criteria = null,
  $orderby = null,
PagingInfo  $pagingInfo = null 
)

◆ loadObjects()

loadObjects (   $type,
  $buildDepth = BuildDepth::SINGLE,
  $criteria = null,
  $orderby = null,
PagingInfo  $pagingInfo = null 
)

◆ loadRelation()

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()

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 AbstractRDBMapper, and NullMapper.

◆ beginTransaction()

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 AbstractRDBMapper, and NullMapper.

◆ commitTransaction()

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 AbstractRDBMapper, and NullMapper.

◆ rollbackTransaction()

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 AbstractRDBMapper, and NullMapper.

◆ getStatements()

getStatements ( )

Get a list of all insert/update/delete statements that where executed in the last transaction.

Note
Different mapper implementations may return different representations
Returns
Array of statements

Implemented in AbstractRDBMapper, and NullMapper.