Class Xyster_Orm_Mapper_Abstract

Description

Implements interfaces:

An abstract implementation of the mapper interface

This class allows for a more simple implementation of the mapper interface, taking care of common logic.

  • copyright: Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net)
  • abstract:
  • license: New BSD License

Located in /Orm/Mapper/Abstract.php (line 47)


	
			
Direct descendents
Class Description
Xyster_Orm_Mapper A SQL implementation of the mapper interface
Variable Summary
Method Summary
Xyster_Orm_Mapper_Abstract __construct (Xyster_Orm_Mapper_Factory_Interface $factory)
void delete (Xyster_Orm_Entity $entity)
Xyster_Orm_Entity get (mixed $id)
string getDomain ()
string getEntityName ()
array getIndex ()
int getLifetime ()
mixed getOption (string $name)
array getOptions ()
Xyster_Orm_Set getSet ([ $entities = null])
string getTable ()
void init ()
void save (Xyster_Orm_Entity $entity)
string translateField (string $field)
string untranslateField (string $field)
Xyster_Orm_Mapper_Abstract _belongsTo (string $name, [ $options = array()])
void _checkPrimaryKey ( $id, mixed $key)
void _checkPropertyNames ( $criteria)
Xyster_Orm_Entity _create (array $row)
int _delete ( $where)
Xyster_Orm_Mapper_Abstract _hasJoined (string $name, [ $options = array()])
Xyster_Orm_Mapper_Abstract _hasMany (string $name, [ $options = array()])
Xyster_Orm_Mapper_Abstract _hasOne (string $name, [ $options = array()])
mixed _insert (Xyster_Orm_Entity $entity)
void _update (Xyster_Orm_Entity $entity)
Variables
string $_domain = "" (line 54)

The domain associated with the entity

  • access: protected

The factory that created this mapper

  • access: protected
array $_index = array() (line 76)

An array of properties used to index the entity by value

The array consists of index names as keys and arrays of the columns contained within as values.

  1. array(
  2.      'name_index' => array'name' ),
  3.   'multi_index' => array'transactionNumber''transactionDate' )
  4.  );

  • access: protected
int $_lifetime = 60 (line 86)

The period of time entities should persist in the secondary cache

A value of -1 means the entity shouldn't be added to secondary cache. A value of 0 means the entity should be stored indefinitely.

  • access: protected
array $_options = array() (line 112)

Any additional options

<dl> <dt>metadataCache</dt><dd>The name of the Zend_Registry key to find a Zend_Cache_Core object for caching metadata information. If not specified, the mapper will use the defaultMetadataCache.</dd> <dt>doNotRefreshAfterSave</dt><dd>This will cause the mapper not to refresh the entity after it's inserted or updated.</dd> <dt>locking</dt><dd>The name of the field which holds an integer version number of the record (used to avoid concurrent changes)</dd> <dt>doNotCreateValidators</dt><dd>This will cause the mapper not to create validators from the constraints in the data store.</dd> </dl>

  • access: protected
string $_table = "" (line 119)

The name of the table, defaults to entity name

  • access: protected
Methods
Constructor __construct (line 128)

Creates a new mapper

Class authors can overwrite this, but <em>be sure to call the parent</em>

  • access: public
Xyster_Orm_Mapper_Abstract __construct (Xyster_Orm_Mapper_Factory_Interface $factory)

Redefined in descendants as:
delete (line 152)

Deletes an entity

  • access: public
void delete (Xyster_Orm_Entity $entity)

Implementation of:
Xyster_Orm_Mapper_Interface::delete()
Deletes an entity
get (line 198)

Gets an entity with the supplied identifier

  • return: The data entity found, or null if none
  • access: public
Xyster_Orm_Entity get (mixed $id)
  • mixed $id: The id of the entity to get

Implementation of:
Xyster_Orm_Mapper_Interface::get()
Gets an entity with the supplied identifier
getDomain (line 226)

Gets the name of the domain to which this mapper belongs

  • return: The domain
  • access: public
string getDomain ()

Implementation of:
Xyster_Orm_Mapper_Interface::getDomain()
Gets the name of the domain to which this mapper belongs
getEntityName (line 254)

Gets the class name of the entity

Class authors should overwrite this method if their entity name isn't the same as the mapper name.

  • return: The class name of the entity
  • access: public
string getEntityName ()

Implementation of:
Xyster_Orm_Mapper_Interface::getEntityName()
Gets the class name of the entity
getEntityType (line 236)

Gets the entity metadata

  • access: public
Xyster_Orm_Entity_Type getEntityType ()

Implementation of:
Xyster_Orm_Mapper_Interface::getEntityType()
Gets the entity metadata
getFactory (line 264)

Gets the factory that created this mapper

  • access: public

Implementation of:
Xyster_Orm_Mapper_Interface::getFactory()
Gets the factory that created the mapper
getIndex (line 277)

Gets the columns that should be used to index the entity

The array consists of index names as keys and arrays of the columns contained within as values.

  • access: public
array getIndex ()

Implementation of:
Xyster_Orm_Mapper_Interface::getIndex()
Gets the columns that should be used to index the entity
getLifetime (line 287)

Gets the time in seconds an entity should be cached

  • access: public
int getLifetime ()

Implementation of:
Xyster_Orm_Mapper_Interface::getLifetime()
Gets the time in seconds an entity should be cached
getOption (line 298)

Gets the value of an option

  • return: The option value
  • access: public
mixed getOption (string $name)
  • string $name: The name of the option

Implementation of:
Xyster_Orm_Mapper_Interface::getOption()
Gets the value of an option
getOptions (line 309)

Gets the options for this mapper

  • access: public
array getOptions ()

Implementation of:
Xyster_Orm_Mapper_Interface::getOptions()
Gets the options for this mapper
getSet (line 319)

Gets an empty entity set for the mapper's entity type

  • return: An empty set
  • access: public
Xyster_Orm_Set getSet ([ $entities = null])

Implementation of:
Xyster_Orm_Mapper_Interface::getSet()
Gets an empty entity set for the mapper's entity type
getTable (line 333)

Gets the table from which an entity comes

It is up to the Xyster_Orm_Backend to do something with this value.

  • return: The table name
  • access: public
string getTable ()

Implementation of:
Xyster_Orm_Mapper_Interface::getTable()
Gets the table from which an entity comes
init (line 143)

Allows for subclassing without overwriting constructor

The mapper factory calls this method. This is necessary because the init method should contain the setup of relations, which might depend on the mapper that's still being instantiated in the factory.

  • access: public
void init ()

Implementation of:
Xyster_Orm_Mapper_Interface::init()
Allows for subclassing without overwriting constructor
save (line 347)

Saves an entity (insert or update)

  • access: public
void save (Xyster_Orm_Entity $entity)

Implementation of:
Xyster_Orm_Mapper_Interface::save()
Saves an entity (insert or update)
translateField (line 455)
  • access: public
string translateField (string $field)
  • string $field

Implementation of:
Xyster_Orm_Mapper_Interface::translateField()
Translates the field from the original format into the entity field name
untranslateField (line 466)
  • access: public
string untranslateField (string $field)
  • string $field

Implementation of:
Xyster_Orm_Mapper_Interface::untranslateField()
Translates the field from the entity format back into the original
_addValidators (line 523)

Adds the validators from the constraints in the data store

Right now we add a NotEmpty validator for fields declared as NOT NULL. We also try to match integer types in the form of TINYINT, BIGINT, SMALLINT, INT, INTEGER and any variations. We also try to match float values in the form of FLOAT, REAL, DOUBLE, and DOUBLE PRECISION.

  • access: protected
void _addValidators (Xyster_Orm_Entity_Type $type)
_assertThisType (line 550)

A convenience method to assert entity type

  • throws: Xyster_Orm_Mapper_Exception if the entity supplied is of the wrong type
  • access: protected
void _assertThisType (Xyster_Orm_Entity $entity)
_belongsTo (line 566)

Convenience method to create a 'belongs' relationship

  • return: provides a fluent interface
  • see: Xyster_Orm_Entity_Type::belongsTo
  • access: protected
Xyster_Orm_Mapper_Abstract _belongsTo (string $name, [ $options = array()])
  • string $name: The name of the relationship
  • array $options: An array of options
_buildCriteria (line 578)

Ensures the parameter passed is a Criterion

  • access: protected
Xyster_Data_Criterion _buildCriteria (Xyster_Data_Criterion|array $criteria)
_checkPrimaryKey (line 615)

Checks an array for correct primary key names

  • access: protected
void _checkPrimaryKey ( $id, mixed $key)
  • mixed $key
  • $id
_checkPropertyNames (line 644)

Asserts the correct property names in a criteria array

  • throws: Xyster_Orm_Mapper_Exception if one of the field names is invalid
  • access: protected
void _checkPropertyNames ( $criteria)
  • array $criteria
_create (line 669)

Creates an entity from the row supplied

If the row has already been loaded and the entity that represents the row is in the repository, this method will return that exact instance instead of creating a new one.

  • return: The entity created
  • access: protected
Xyster_Orm_Entity _create (array $row)
  • array $row
_delete (line 477)

Removes entities from the backend

  • return: The number of rows deleted
  • abstract:
  • access: protected
int _delete ( $where)

Redefined in descendants as:
_hasJoined (line 695)

Convenience method to create a 'many to many' relationship

  • return: provides a fluent interface
  • see: Xyster_Orm_Entity_Type::hasJoined
  • access: protected
Xyster_Orm_Mapper_Abstract _hasJoined (string $name, [ $options = array()])
  • string $name: The name of the relationship
  • array $options: An array of options
_hasMany (line 709)

Convenience method to create a 'one to many' relationship

  • return: provides a fluent interface
  • see: Xyster_Orm_Entity_Type::hasMany
  • access: protected
Xyster_Orm_Mapper_Abstract _hasMany (string $name, [ $options = array()])
  • string $name: The name of the relationship
  • array $options: An array of options
_hasOne (line 723)

Convenience method to create a 'one to one' relationship

  • return: provides a fluent interface
  • see: Xyster_Orm_Entity_Type::hasOne
  • access: protected
Xyster_Orm_Mapper_Abstract _hasOne (string $name, [ $options = array()])
  • string $name: The name of the relationship
  • array $options: An array of options
_insert (line 485)

Saves a new entity into the backend

  • return: The new primary key
  • abstract:
  • access: protected
mixed _insert (Xyster_Orm_Entity $entity)

Redefined in descendants as:
_joinedDelete (line 499)

Removes the entity from the many-to-many join

  • abstract:
  • access: protected
void _joinedDelete (Xyster_Orm_Set $set)

Redefined in descendants as:
_joinedInsert (line 492)

Adds the entity to the many-to-many join

  • abstract:
  • access: protected
void _joinedInsert (Xyster_Orm_Set $set)

Redefined in descendants as:
_update (line 511)

Updates the values of an entity in the backend

Class authors must remember to implement optimistic offline locking in this method. See the Xyster_Orm_Mapper::_update method for an example.

  • abstract:
  • throws: Xyster_Orm_Mapper_Exception if the record was modified or deleted
  • access: protected
void _update (Xyster_Orm_Entity $entity)

Redefined in descendants as:

Documentation generated on Mon, 19 May 2008 17:06:53 -0400 by phpDocumentor 1.4.2