Class Xyster_Orm_Entity_Type

Description

A helper for meta information about entities

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

Located in /Orm/Entity/Type.php (line 36)

Xyster_Type
   |
   --Xyster_Orm_Entity_Type
Variable Summary
Xyster_Orm_Entity_Field[] $_fields
Xyster_Orm_Entity_Lookup_Interface[] $_lookups
array $_members
array $_primary
array $_relations
array $_runtime
boolean $_validate
Method Summary
Xyster_Orm_Entity_Type __construct (Xyster_Orm_Mapper_Interface $map)
Xyster_Orm_Entity_Type addValidator ( $name,  $validator, [boolean $breakChainOnFailure = false], string $field)
void assertValidField (string $field)
Xyster_Orm_Relation belongsTo (string $name, [ $options = array()])
Xyster_Orm_Entity_Type disableValidation ([boolean $flag = true])
string getEntityName ()
array getFieldNames ()
array getFields ()
array getLookupNames ()
array getMembers ()
array getPrimary ()
array getRelationNames ()
array getRelations ()
Zend_Validate getValidators (string $field)
Xyster_Orm_Relation hasJoined (string $name, [ $options = array()])
Xyster_Orm_Relation hasMany (string $name, [ $options = array()])
Xyster_Orm_Relation hasOne (string $name, [ $options = array()])
boolean isLookup (string $name)
boolean isRelation (string $name)
boolean isRuntime ( $object, string $class)
boolean isValidateOnSave ()
boolean isValidationEnabled ()
boolean validate (string $name, mixed $value, [ $throwOnFail = false], boolean $fail)
Xyster_Orm_Entity_Type validateOnSave ([boolean $flag = true])
Xyster_Orm_Relation _baseCreate (string $type, string $name,  $options)
boolean _isRuntime ( $field)
Variables
Xyster_Orm_Entity_Field[] $_fields = array() (line 43)

Cache for entity fields

  • access: protected
Xyster_Orm_Entity_Lookup_Interface[] $_lookups = array() (line 50)

An array of Xyster_Orm_Entity_Lookup_Interface objects

  • access: protected
Xyster_Orm_Mapper_Factory_Interface $_mapFactory (line 57)

The mapper factory

  • access: protected
array $_members = array() (line 64)

A cache for all entity members

  • access: protected
array $_primary = array() (line 71)

The field names of the primary key

  • access: protected
array $_relations = array() (line 78)

The relation objects

  • access: protected
array $_runtime = array() (line 85)

The cache for runtime column lookups

  • access: protected
boolean $_validate = true (line 92)

Whether validation is enabled for this type

  • access: protected
boolean $_validateOnSave = false (line 99)

Whether to validate entities when saved or per-field

  • access: protected

Inherited Variables

Inherited from Xyster_Type

Xyster_Type::$_class
Xyster_Type::$_type
Methods
Constructor __construct (line 106)

Creates a new Entity type representation

  • access: public
Xyster_Orm_Entity_Type __construct (Xyster_Orm_Mapper_Interface $map)

Redefinition of:
Xyster_Type::__construct()
Creates a new type representation
addLookup (line 127)

Adds a lookup to the entity type

  • return: provides a fluent interface
  • access: public
addValidator (line 156)

Adds a validator for a field

  • return: provides a fluent interface
  • throws: Xyster_Orm_Entity_Exception if the field is invalid for this type
  • access: public
Xyster_Orm_Entity_Type addValidator ( $name,  $validator, [boolean $breakChainOnFailure = false], string $field)
  • string $field: The field name
  • Zend_Validate_Interface $validator: The validator
  • boolean $breakChainOnFailure: Whether to break after fail
  • $name
assertValidField (line 168)

Asserts a field's presence in the entity class' members

  • throws: Xyster_Orm_Entity_Exception
  • access: public
void assertValidField (string $field)
  • string $field
belongsTo (line 253)

Creates a 'one to one' relationship for entities on the 'many' end of a 'one to many' relationship

Options can contain the following values:

<dl> <dt>class</dt><dd>The foreign class. The relation name by default</dd> <dt>id</dt><dd>The name of the foreign key field(s) on the declaring entity. This should either be an array (if multiple) or a string (if one). By default, this is classId</dd> <dt>filters</dt><dd>In XSQL, any Criteria that should be used against the entity to be loaded</dd> </dl>

  • return: The relationship created
  • access: public
Xyster_Orm_Relation belongsTo (string $name, [ $options = array()])
  • string $name: The name of the relationship
  • array $options: An array of options
disableValidation (line 264)

Disables validation for this entity type. USE WITH CAUTION.

  • return: provides a fluent interface
  • access: public
Xyster_Orm_Entity_Type disableValidation ([boolean $flag = true])
  • boolean $flag
getEntityName (line 275)

Gets the class name of the entity

  • return: The class name
  • access: public
string getEntityName ()
getField (line 287)

Gets a field by name

  • throws: Xyster_Orm_Entity_Exception if the field is invalid for this type
  • access: public
Xyster_Orm_Entity_Field getField (string $name)
  • string $name
getFieldNames (line 301)

Gets the names of the fields for the entity

  • return: An array of field names
  • access: public
array getFieldNames ()
getFields (line 311)

Gets the fields for the entity

array getFields ()
getLookup (line 323)

Gets the lookup by name

  • throws: Xyster_Orm_Entity_Exception if the name is invalid
  • access: public
Xyster_Orm_Entity_Lookup_Interface getLookup (string $name)
  • string $name: the name of the lookup
getLookupNames (line 339)

Gets the names of all lookups defined for this entity

  • return: The names of defined lookups
  • access: public
array getLookupNames ()
getMapperFactory (line 349)

Gets the mapper factory

  • access: public
getMembers (line 359)

Gets all available class members (fields, relations, and methods)

  • access: public
array getMembers ()
getPrimary (line 375)

Gets an array containing the field name or names for the primary key

  • return: The field names
  • access: public
array getPrimary ()
getRelation (line 388)

Gets the relationship by name

  • throws: Xyster_Orm_Relation_Exception if the relationship name is invalid
  • access: public
Xyster_Orm_Relation getRelation (string $name)
  • string $name: The name of the relationship
getRelationNames (line 404)

Gets the names of all relations defined for this entity

  • return: The names of defined relations
  • access: public
array getRelationNames ()
getRelations (line 414)

Gets the relations for the entity

array getRelations ()
getValidators (line 429)

Gets the validators for a field

This method returns a single Zend_Validate object containing all of the validators for the field. It will return null if there are no validators.

  • throws: Xyster_Orm_Entity_Exception if the field is invalid for this type
  • access: public
Zend_Validate getValidators (string $field)
  • string $field: The name of the field
hasJoined (line 502)

Creates a 'many to many' relationship

<dl> <dt>class</dt><dd>The class of entity to load through the join table. It will be the relationship name minus a trailing 's' by default.</dd> <dt>table</dt><dd>The join table name. By default this will be declaring_class_class</dd> <dt>left</dt><dd>The column(s) in the join table referencing the declaringClass entity. By default: declaring_class_id</dd> <dt>right</dt><dd>The column(s) in the join table referencing the foreign entity. By default, it's class_name_id</dd> <dt>filters</dt><dd>In XSQL, any Criteria that should be used against the join table. Column names should be specified in the format native to the data store (i.e. with underscores, not camelCase)</dd> </dl>

  • return: The relationship created
  • access: public
Xyster_Orm_Relation hasJoined (string $name, [ $options = array()])
  • string $name: The name of the relationship
  • array $options: An array of options
hasMany (line 476)

Creates a 'one to many' relationship

Options can contain the following values:

<dl> <dt>class</dt><dd>The foreign class. The relation name minus a trailing 's' by default</dd> <dt>id</dt><dd>The name of the foreign key field(s) on the related entity. This should either be an array (if multiple) or a string (if one). By default, this is classId</dd> <dt>filters</dt><dd>In XSQL, any Criteria that should be used against the entities to be loaded</dd> </dl>

  • return: The relationship created
  • access: public
Xyster_Orm_Relation hasMany (string $name, [ $options = array()])
  • string $name: The name of the relationship
  • array $options: An array of options
hasOne (line 452)

Creates a 'one to one' relationship

Options can contain the following values:

<dl> <dt>class</dt><dd>The foreign class. The relation name by default</dd> <dt>id</dt><dd>The name of the foreign key field(s) on the declaring entity. This should either be an array (if multiple) or a string (if one). By default, this is classId</dd> <dt>filters</dt><dd>In XSQL, any Criteria that should be used against the entity to be loaded</dd> </dl>

  • return: The relationship created
  • access: public
Xyster_Orm_Relation hasOne (string $name, [ $options = array()])
  • string $name: The name of the relationship
  • array $options: An array of options
isLookup (line 513)

Whether the entity has a lookup with the name supplied

  • access: public
boolean isLookup (string $name)
  • string $name: The name of the lookup
isRelation (line 524)

Whether the entity has a relationship with the name supplied

  • access: public
boolean isRelation (string $name)
  • string $name: The name of the relationship
isRuntime (line 536)

Verifies if a Xyster_Data_Symbol is runtime

  • access: public
boolean isRuntime ( $object, string $class)
isValidateOnSave (line 570)

Whether this entity should be validated before save (instead of field)

  • access: public
boolean isValidateOnSave ()
isValidationEnabled (line 580)

Whether validation is enabled for this entity type

  • access: public
boolean isValidationEnabled ()
validate (line 594)

Validates a field

  • return: Whether the value is valid for the field
  • throws: Xyster_Orm_Entity_Exception if the field is invalid for this type
  • access: public
boolean validate (string $name, mixed $value, [ $throwOnFail = false], boolean $fail)
  • string $name: The field name
  • mixed $value: The proposed value
  • boolean $fail: Whether to throw an exception if validation fails
  • $throwOnFail
validateOnSave (line 620)

Sets the validate-on-save setting

  • return: provides a fluent interface
  • access: public
Xyster_Orm_Entity_Type validateOnSave ([boolean $flag = true])
  • boolean $flag
_baseCreate (line 635)

Base creator method

  • throws: Xyster_Orm_Relation_Exception if the relationship is already defined
  • access: protected
Xyster_Orm_Relation _baseCreate (string $type, string $name,  $options)
  • string $type: The type of the relationship
  • string $name: The name of the relationship
  • array $options: An array of options
_isRuntime (line 656)

Returns if a field is runtime

  • access: protected
boolean _isRuntime ( $field)

Inherited Methods

Inherited From Xyster_Type

Xyster_Type::__construct()
Xyster_Type::areDeeplyEqual()
Xyster_Type::areEqual()
Xyster_Type::equals()
Xyster_Type::getClass()
Xyster_Type::getForParameters()
Xyster_Type::getName()
Xyster_Type::hash()
Xyster_Type::hashCode()
Xyster_Type::isAssignableFrom()
Xyster_Type::isInstance()
Xyster_Type::isObject()
Xyster_Type::of()
Xyster_Type::_getReflectionClass()
Xyster_Type::__toString()

Documentation generated on Mon, 19 May 2008 17:07:41 -0400 by phpDocumentor 1.4.2