Doctrine_Record renamed. Hydration refactored. Other refactorings.
This commit is contained in:
parent
ad0d24ff57
commit
7ffd4140cd
@ -289,7 +289,7 @@ final class Doctrine
|
||||
/**
|
||||
* FETCHMODE_RECORD
|
||||
*
|
||||
* Specifies that the fetch method shall return Doctrine_Record
|
||||
* Specifies that the fetch method shall return Doctrine_Entity
|
||||
* objects as the elements of the result set.
|
||||
*
|
||||
* This is the default fetchmode.
|
||||
@ -471,6 +471,14 @@ final class Doctrine
|
||||
* @see self::ATTR_HYDRATE
|
||||
*/
|
||||
const HYDRATE_NONE = 4;
|
||||
|
||||
/* new hydration modes. move to Query class when it's time. */
|
||||
//const HYDRATE_IDENTITY_OBJECT = 1; // default, auto-adds PKs, produces object graphs
|
||||
//const HYDRATE_IDENTITY_ARRAY = 2; // auto-adds PKs, produces array graphs
|
||||
//const HYDRATE_SCALAR = 3; // produces flat result list with scalar values
|
||||
//const HYDRATE_SINGLE_SCALAR = 4; // produces a single scalar value
|
||||
//const HYDRATE_NONE = 5; // produces a result set as it's returned by the db
|
||||
|
||||
|
||||
/**
|
||||
* VALIDATE CONSTANTS
|
||||
@ -709,8 +717,8 @@ final class Doctrine
|
||||
*
|
||||
* Get all the loaded models, you can provide an array of classes or it will use get_declared_classes()
|
||||
*
|
||||
* Will filter through an array of classes and return the Doctrine_Records out of them.
|
||||
* If you do not specify $classes it will return all of the currently loaded Doctrine_Records
|
||||
* Will filter through an array of classes and return the Doctrine_Entitys out of them.
|
||||
* If you do not specify $classes it will return all of the currently loaded Doctrine_Entitys
|
||||
*
|
||||
* @return array $loadedModels
|
||||
*/
|
||||
@ -747,7 +755,7 @@ final class Doctrine
|
||||
/**
|
||||
* isValidModelClass
|
||||
*
|
||||
* Checks if what is passed is a valid Doctrine_Record
|
||||
* Checks if what is passed is a valid Doctrine_Entity
|
||||
* Will load class in to memory in order to inflect it and find out information about the class
|
||||
*
|
||||
* @param mixed $class Can be a string named after the class, an instance of the class, or an instance of the class reflected
|
||||
@ -755,7 +763,7 @@ final class Doctrine
|
||||
*/
|
||||
public static function isValidModelClass($class)
|
||||
{
|
||||
if ($class instanceof Doctrine_Record) {
|
||||
if ($class instanceof Doctrine_Entity) {
|
||||
$class = get_class($class);
|
||||
}
|
||||
|
||||
@ -766,10 +774,10 @@ final class Doctrine
|
||||
if ($class instanceof ReflectionClass) {
|
||||
// Skip the following classes
|
||||
// - abstract classes
|
||||
// - not a subclass of Doctrine_Record
|
||||
// - not a subclass of Doctrine_Entity
|
||||
// - don't have a setTableDefinition method
|
||||
if (!$class->isAbstract() &&
|
||||
$class->isSubClassOf('Doctrine_Record')) {
|
||||
$class->isSubClassOf('Doctrine_Entity')) {
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -805,7 +813,7 @@ final class Doctrine
|
||||
/**
|
||||
* generateModelsFromDb
|
||||
*
|
||||
* method for importing existing schema to Doctrine_Record classes
|
||||
* method for importing existing schema to Doctrine_Entity classes
|
||||
*
|
||||
* @param string $directory Directory to write your models to
|
||||
* @param array $databases Array of databases to generate models for
|
||||
|
@ -55,11 +55,11 @@ class Doctrine_AuditLog extends Doctrine_Record_Generator
|
||||
/**
|
||||
* Get the version
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @param mixed $version
|
||||
* @return array An array with version information
|
||||
*/
|
||||
public function getVersion(Doctrine_Record $record, $version)
|
||||
public function getVersion(Doctrine_Entity $record, $version)
|
||||
{
|
||||
$className = $this->_options['className'];
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
/**
|
||||
* Doctrine_Builder_Record
|
||||
*
|
||||
* Import builder is responsible of building Doctrine_Record classes
|
||||
* Import builder is responsible of building Doctrine_Entity classes
|
||||
* based on a database schema.
|
||||
*
|
||||
* @package Doctrine
|
||||
@ -93,7 +93,7 @@ class Doctrine_Builder_Record
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_baseClassName = 'Doctrine_Record';
|
||||
protected $_baseClassName = 'Doctrine_Entity';
|
||||
|
||||
/**
|
||||
* tpl
|
||||
@ -270,7 +270,7 @@ END;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build the table definition of a Doctrine_Record object
|
||||
* Build the table definition of a Doctrine_Entity object
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $tableColumns
|
||||
|
@ -137,6 +137,14 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
* @var array $columns
|
||||
*/
|
||||
protected $_mappedColumns = array();
|
||||
|
||||
/**
|
||||
* The mapped embedded values (value objects).
|
||||
*
|
||||
* @var array
|
||||
* @TODO Implementation (Value Object support)
|
||||
*/
|
||||
protected $_mappedEmbeddedValues = array();
|
||||
|
||||
/**
|
||||
* An array of field names. used to look up field names from column names.
|
||||
@ -171,7 +179,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
protected $_tree;
|
||||
|
||||
/**
|
||||
* Cached column count, Doctrine_Record uses this column count when
|
||||
* Cached column count, Doctrine_Entity uses this column count when
|
||||
* determining its state.
|
||||
*
|
||||
* @var integer
|
||||
@ -1571,7 +1579,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
* binds query parts to given component
|
||||
*
|
||||
* @param array $queryParts an array of pre-bound query parts
|
||||
* @return Doctrine_Record this object
|
||||
* @return Doctrine_Entity this object
|
||||
*/
|
||||
public function bindQueryParts(array $queryParts)
|
||||
{
|
||||
@ -1585,7 +1593,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
*
|
||||
* @param string $queryPart
|
||||
* @param mixed $value
|
||||
* @return Doctrine_Record this object
|
||||
* @return Doctrine_Entity this object
|
||||
*/
|
||||
public function bindQueryPart($queryPart, $value)
|
||||
{
|
||||
@ -1719,7 +1727,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
*
|
||||
* @param mixed $constraint either a SQL constraint portion or an array of CHECK constraints
|
||||
* @param string $name optional constraint name
|
||||
* @return Doctrine_Record this object
|
||||
* @return Doctrine_Entity this object
|
||||
* @todo Should be done through $_tableOptions
|
||||
*/
|
||||
public function check($constraint, $name = null)
|
||||
@ -1834,7 +1842,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
* @param string $componentName the name of the related component
|
||||
* @param string $options relation options
|
||||
* @see Doctrine_Relation::_$definition
|
||||
* @return Doctrine_Record this object
|
||||
* @return Doctrine_Entity this object
|
||||
*/
|
||||
public function hasOne()
|
||||
{
|
||||
@ -1850,7 +1858,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
|
||||
* @param string $componentName the name of the related component
|
||||
* @param string $options relation options
|
||||
* @see Doctrine_Relation::_$definition
|
||||
* @return Doctrine_Record this object
|
||||
* @return Doctrine_Entity this object
|
||||
*/
|
||||
public function hasMany()
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ class Doctrine_ClassMetadata_Factory
|
||||
$parentClasses = array();
|
||||
$loadedParentClass = false;
|
||||
while ($parentClass = get_parent_class($parentClass)) {
|
||||
if ($parentClass == 'Doctrine_Record') {
|
||||
if ($parentClass == 'Doctrine_Entity') {
|
||||
break;
|
||||
}
|
||||
if (isset($classes[$parentClass])) {
|
||||
@ -159,7 +159,7 @@ class Doctrine_ClassMetadata_Factory
|
||||
$className = $name;
|
||||
// get parent classes
|
||||
do {
|
||||
if ($className === 'Doctrine_Record') {
|
||||
if ($className === 'Doctrine_Entity') {
|
||||
break;
|
||||
} else if ($className == $name) {
|
||||
continue;
|
||||
|
@ -58,7 +58,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
/**
|
||||
* This record this collection is attached to, if any.
|
||||
*
|
||||
* @var Doctrine_Record
|
||||
* @var Doctrine_Entity
|
||||
*/
|
||||
protected $reference;
|
||||
|
||||
@ -308,7 +308,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setReference(Doctrine_Record $record, Doctrine_Relation $relation)
|
||||
public function setReference(Doctrine_Entity $record, Doctrine_Relation $relation)
|
||||
{
|
||||
$this->reference = $record;
|
||||
$this->relation = $relation;
|
||||
@ -368,7 +368,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function search(Doctrine_Record $record)
|
||||
public function search(Doctrine_Entity $record)
|
||||
{
|
||||
return array_search($record, $this->data, true);
|
||||
}
|
||||
@ -388,7 +388,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
* Collection also maps referential information to newly created records
|
||||
*
|
||||
* @param mixed $key the key of the element
|
||||
* @return Doctrine_Record return a specified record
|
||||
* @return Doctrine_Entity return a specified record
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
@ -481,15 +481,15 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
/**
|
||||
* set
|
||||
* @param integer $key
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return void
|
||||
* @internal Can't type-hint the second parameter to Doctrine_Record because we need
|
||||
* @internal Can't type-hint the second parameter to Doctrine_Entity because we need
|
||||
* to adhere to the Doctrine_Access::set() signature.
|
||||
*/
|
||||
public function set($key, $record)
|
||||
{
|
||||
if ( ! $record instanceOf Doctrine_Record) {
|
||||
throw new Doctrine_Collection_Exception('Value variable in set is not an instance of Doctrine_Record');
|
||||
if ( ! $record instanceOf Doctrine_Entity) {
|
||||
throw new Doctrine_Collection_Exception('Value variable in set is not an instance of Doctrine_Entity');
|
||||
}
|
||||
|
||||
if (isset($this->referenceField)) {
|
||||
@ -500,14 +500,14 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
|
||||
/**
|
||||
* adds a record to collection
|
||||
* @param Doctrine_Record $record record to be added
|
||||
* @param Doctrine_Entity $record record to be added
|
||||
* @param string $key optional key for the record
|
||||
* @return boolean
|
||||
*/
|
||||
public function add($record, $key = null)
|
||||
{
|
||||
if ( ! $record instanceof Doctrine_Record) {
|
||||
throw new Doctrine_Record_Exception('Value variable in set is not an instance of Doctrine_Record.');
|
||||
if ( ! $record instanceof Doctrine_Entity) {
|
||||
throw new Doctrine_Record_Exception('Value variable in set is not an instance of Doctrine_Entity.');
|
||||
}
|
||||
|
||||
if (isset($this->referenceField)) {
|
||||
|
@ -96,7 +96,7 @@ abstract class Doctrine_Collection_Iterator implements Iterator
|
||||
/**
|
||||
* returns the current record
|
||||
*
|
||||
* @return Doctrine_Record
|
||||
* @return Doctrine_Entity
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
/**
|
||||
* Doctrine_Collection_Offset
|
||||
* Collection of Doctrine_Record objects.
|
||||
* Collection of Doctrine_Entity objects.
|
||||
*
|
||||
* @package Doctrine
|
||||
* @subpackage Collection
|
||||
|
@ -144,6 +144,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
/*
|
||||
* ----------- EntityManager attributes ---------------
|
||||
*/
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_ems = array();
|
||||
|
||||
/**
|
||||
* The metadata factory is used to retrieve the metadata of entity classes.
|
||||
*
|
||||
@ -1129,14 +1136,26 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ----------- EntityManager methods ---------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the EntityManager that is responsible for the Entity.
|
||||
*
|
||||
* @param string $entityName
|
||||
* @return EntityManager
|
||||
*/
|
||||
public static function getManagerForEntity($entityName)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
/**
|
||||
* query
|
||||
* queries the database using Doctrine Query Language
|
||||
* returns a collection of Doctrine_Record objects
|
||||
* returns a collection of Doctrine_Entity objects
|
||||
*
|
||||
* <code>
|
||||
* $users = $conn->query('SELECT u.* FROM User u');
|
||||
@ -1148,7 +1167,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param array $params query parameters
|
||||
* @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD
|
||||
* @see Doctrine_Query
|
||||
* @return Doctrine_Collection Collection of Doctrine_Record objects
|
||||
* @return Doctrine_Collection Collection of Doctrine_Entity objects
|
||||
* @todo package:orm
|
||||
*/
|
||||
public function query($query, array $params = array(), $hydrationMode = null)
|
||||
@ -1174,7 +1193,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
* @param string $query DQL query
|
||||
* @param array $params query parameters
|
||||
* @see Doctrine_Query
|
||||
* @return Doctrine_Record|false Doctrine_Record object on success,
|
||||
* @return Doctrine_Entity|false Doctrine_Entity object on success,
|
||||
* boolean false on failure
|
||||
*/
|
||||
public function queryOne($query, array $params = array())
|
||||
@ -1301,7 +1320,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
*
|
||||
* create creates a record
|
||||
* @param string $name component name
|
||||
* @return Doctrine_Record Doctrine_Record object
|
||||
* @return Doctrine_Entity Doctrine_Entity object
|
||||
* @todo Any strong reasons why this should not be removed?
|
||||
* @todo package:orm
|
||||
*/
|
||||
@ -1377,12 +1396,12 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
$this->exported = array();
|
||||
}
|
||||
|
||||
public function save(Doctrine_Record $entity, $conn = null)
|
||||
public function save(Doctrine_Entity $entity, $conn = null)
|
||||
{
|
||||
$this->getMapper($entity->getClassName())->save($entity, $conn);
|
||||
}
|
||||
|
||||
public function remove(Doctrine_Record $entity, $conn = null)
|
||||
public function remove(Doctrine_Entity $entity, $conn = null)
|
||||
{
|
||||
$this->getMapper($entity->getClassName())->delete($entity, $conn);
|
||||
}
|
||||
@ -1392,17 +1411,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
return $this->getMapper($entityName)->create($data);
|
||||
}
|
||||
|
||||
public function detach(Doctrine_Record $entity)
|
||||
public function detach(Doctrine_Entity $entity)
|
||||
{
|
||||
$this->getMapper($entity->getClassName())->detach($entity);
|
||||
}
|
||||
|
||||
public function removeRecord(Doctrine_Record $entity)
|
||||
public function removeRecord(Doctrine_Entity $entity)
|
||||
{
|
||||
$this->getMapper($entity->getClassName())->removeRecord($entity);
|
||||
}
|
||||
|
||||
public function manage(Doctrine_Record $entity)
|
||||
public function manage(Doctrine_Entity $entity)
|
||||
{
|
||||
$this->getMapper($entity->getClassName())->manage($entity);
|
||||
}
|
||||
@ -1503,6 +1522,77 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
|
||||
return $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* createEntity
|
||||
* First checks if record exists in identityMap, if not
|
||||
* returns a new record.
|
||||
*
|
||||
* @return Doctrine_Entity
|
||||
*/
|
||||
public function createEntity2($className, array $data)
|
||||
{
|
||||
$className = $this->_getClassnameToReturn($data, $className);
|
||||
$classMetadata = $this->getClassMetadata($className);
|
||||
if ( ! empty($data)) {
|
||||
$identifierFieldNames = $classMetadata->getIdentifier();
|
||||
$isNew = false;
|
||||
foreach ($identifierFieldNames as $fieldName) {
|
||||
if ( ! isset($data[$fieldName])) {
|
||||
// id field not found return new entity
|
||||
$isNew = true;
|
||||
break;
|
||||
}
|
||||
$id[] = $data[$fieldName];
|
||||
}
|
||||
if ($isNew) {
|
||||
return new $className(true, $data);
|
||||
}
|
||||
|
||||
$idHash = $this->unitOfWork->getIdentifierHash($id);
|
||||
|
||||
if ($entity = $this->unitOfWork->tryGetByIdHash($idHash,
|
||||
$classMetadata->getRootClassName())) {
|
||||
// @todo return $entity; the one in-memory is the most recent.
|
||||
$entity->hydrate($data);
|
||||
} else {
|
||||
$entity = new $className(false, $data);
|
||||
$this->unitOfWork->registerIdentity($entity);
|
||||
}
|
||||
$data = array();
|
||||
} else {
|
||||
$entity = new $className(true, $data);
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the dataset for a discriminator column to determine the correct
|
||||
* class to instantiate. If no discriminator column is found, the given
|
||||
* classname will be returned.
|
||||
*
|
||||
* @return string The name of the class to instantiate.
|
||||
* @todo Can be optimized performance-wise.
|
||||
* @todo Move to EntityManager::createEntity()
|
||||
*/
|
||||
protected function _getClassnameToReturn(array $data, $className)
|
||||
{
|
||||
$class = $this->getClassMetadata($className);
|
||||
|
||||
$discCol = $class->getInheritanceOption('discriminatorColumn');
|
||||
if ( ! $discCol) {
|
||||
return $className;
|
||||
}
|
||||
|
||||
$discMap = $class->getInheritanceOption('discriminatorMap');
|
||||
|
||||
if (isset($data[$discCol], $discMap[$data[$discCol]])) {
|
||||
return $discMap[$data[$discCol]];
|
||||
} else {
|
||||
return $className;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -119,7 +119,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
/**
|
||||
* Register a new entity.
|
||||
*/
|
||||
public function registerNew(Doctrine_Record $entity)
|
||||
public function registerNew(Doctrine_Entity $entity)
|
||||
{
|
||||
if ( ! $entity->identifier()) {
|
||||
throw new Doctrine_Connection_Exception("Entity without identity "
|
||||
@ -136,7 +136,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
$this->_newEntities[$oid] = $entity;
|
||||
}
|
||||
|
||||
public function isRegisteredNew(Doctrine_Record $entity)
|
||||
public function isRegisteredNew(Doctrine_Entity $entity)
|
||||
{
|
||||
return isset($this->_newEntities[$entity->getOid()]);
|
||||
}
|
||||
@ -144,7 +144,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
/**
|
||||
* Registers a clean entity.
|
||||
*/
|
||||
public function registerClean(Doctrine_Record $entity)
|
||||
public function registerClean(Doctrine_Entity $entity)
|
||||
{
|
||||
$this->registerIdentity($entity);
|
||||
}
|
||||
@ -152,7 +152,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
/**
|
||||
* Registers a dirty entity.
|
||||
*/
|
||||
public function registerDirty(Doctrine_Record $entity)
|
||||
public function registerDirty(Doctrine_Entity $entity)
|
||||
{
|
||||
if ( ! $entity->identifier()) {
|
||||
throw new Doctrine_Connection_Exception("Entity without identity "
|
||||
@ -167,7 +167,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
}
|
||||
}
|
||||
|
||||
public function isRegisteredDirty(Doctrine_Record $entity)
|
||||
public function isRegisteredDirty(Doctrine_Entity $entity)
|
||||
{
|
||||
return isset($this->_dirtyEntities[$entity->getOid()]);
|
||||
}
|
||||
@ -175,7 +175,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
/**
|
||||
* Registers a deleted entity.
|
||||
*/
|
||||
public function registerRemoved(Doctrine_Record $entity)
|
||||
public function registerRemoved(Doctrine_Entity $entity)
|
||||
{
|
||||
if ($entity->isTransient()) {
|
||||
return;
|
||||
@ -194,7 +194,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
}
|
||||
}
|
||||
|
||||
public function isRegisteredRemoved(Doctrine_Record $entity)
|
||||
public function isRegisteredRemoved(Doctrine_Entity $entity)
|
||||
{
|
||||
return isset($this->_removedEntities[$entity->getOid()]);
|
||||
}
|
||||
@ -342,7 +342,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
* Adds an entity to the pool of managed entities.
|
||||
* @deprecated
|
||||
*/
|
||||
public function manage(Doctrine_Record $entity)
|
||||
public function manage(Doctrine_Entity $entity)
|
||||
{
|
||||
$oid = $entity->getOid();
|
||||
if ( ! isset($this->_managedEntities[$oid])) {
|
||||
@ -357,7 +357,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
* @return boolean whether ot not the operation was successful
|
||||
* @deprecated
|
||||
*/
|
||||
public function detach(Doctrine_Record $entity)
|
||||
public function detach(Doctrine_Entity $entity)
|
||||
{
|
||||
$oid = $entity->getOid();
|
||||
if ( ! isset($this->_managedEntities[$oid])) {
|
||||
@ -386,7 +386,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
* the entity in question is already managed.
|
||||
* @throws Doctrine_Connection_Exception If the entity has no (database) identity.
|
||||
*/
|
||||
public function registerIdentity(Doctrine_Record $entity)
|
||||
public function registerIdentity(Doctrine_Entity $entity)
|
||||
{
|
||||
$idHash = $this->getIdentifierHash($entity->identifier());
|
||||
if ( ! $idHash) {
|
||||
@ -406,7 +406,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
$this->_identityMap[$entityName] = array();
|
||||
}
|
||||
|
||||
public function unregisterIdentity(Doctrine_Record $entity)
|
||||
public function unregisterIdentity(Doctrine_Entity $entity)
|
||||
{
|
||||
$idHash = $this->getIdentifierHash($entity->identifier());
|
||||
if ( ! $idHash) {
|
||||
@ -443,10 +443,10 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
/**
|
||||
* Checks whether an entity is registered in the identity map.
|
||||
*
|
||||
* @param Doctrine_Record $entity
|
||||
* @param Doctrine_Entity $entity
|
||||
* @return boolean
|
||||
*/
|
||||
public function contains(Doctrine_Record $entity)
|
||||
public function contains(Doctrine_Entity $entity)
|
||||
{
|
||||
$id = implode(' ', $entity->identifier());
|
||||
if ( ! $id) {
|
||||
|
@ -242,13 +242,13 @@ class Doctrine_Data
|
||||
/**
|
||||
* isRelation
|
||||
*
|
||||
* Check if a fieldName on a Doctrine_Record is a relation, if it is we return that relationData
|
||||
* Check if a fieldName on a Doctrine_Entity is a relation, if it is we return that relationData
|
||||
*
|
||||
* @param string $Doctrine_Record
|
||||
* @param string $Doctrine_Entity
|
||||
* @param string $fieldName
|
||||
* @return void
|
||||
*/
|
||||
public function isRelation(Doctrine_Record $record, $fieldName)
|
||||
public function isRelation(Doctrine_Entity $record, $fieldName)
|
||||
{
|
||||
$relations = $record->getTable()->getRelations();
|
||||
|
||||
@ -267,7 +267,7 @@ class Doctrine_Data
|
||||
/**
|
||||
* purge
|
||||
*
|
||||
* Purge all data for loaded models or for the passed array of Doctrine_Records
|
||||
* Purge all data for loaded models or for the passed array of Doctrine_Entitys
|
||||
*
|
||||
* @param string $models
|
||||
* @return void
|
||||
|
@ -289,7 +289,7 @@ class Doctrine_Data_Import extends Doctrine_Data
|
||||
}
|
||||
}
|
||||
|
||||
public function populateDummyRecord(Doctrine_Record $record)
|
||||
public function populateDummyRecord(Doctrine_Entity $record)
|
||||
{
|
||||
$lorem = explode(' ', "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
|
||||
Ipsum has been the industry's standard dummy text ever since the 1500s, when an
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id$
|
||||
* $Id: Record.php 4342 2008-05-08 14:17:35Z romanb $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Doctrine_Record
|
||||
* Doctrine_Entity
|
||||
* All record classes should inherit this super class
|
||||
*
|
||||
* @package Doctrine
|
||||
@ -29,12 +29,12 @@
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.phpdoctrine.org
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
* @since 2.0
|
||||
* @version $Revision: 4342 $
|
||||
* @todo Rename to "Entity". Split up into "Entity" and "ActiveEntity (extends Entity)"???
|
||||
* @todo Remove as many methods as possible.
|
||||
*/
|
||||
abstract class Doctrine_Record extends Doctrine_Access implements Countable, IteratorAggregate, Serializable
|
||||
abstract class Doctrine_Entity extends Doctrine_Access implements Countable, IteratorAggregate, Serializable
|
||||
{
|
||||
/**
|
||||
* STATE CONSTANTS
|
||||
@ -42,39 +42,39 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
|
||||
/**
|
||||
* DIRTY STATE
|
||||
* a Doctrine_Record is in dirty state when its properties are changed
|
||||
* a Doctrine_Entity is in dirty state when its properties are changed
|
||||
*/
|
||||
const STATE_DIRTY = 1;
|
||||
|
||||
/**
|
||||
* TDIRTY STATE
|
||||
* a Doctrine_Record is in transient dirty state when it is created
|
||||
* a Doctrine_Entity is in transient dirty state when it is created
|
||||
* and some of its fields are modified but it is NOT yet persisted into database
|
||||
*/
|
||||
const STATE_TDIRTY = 2;
|
||||
|
||||
/**
|
||||
* CLEAN STATE
|
||||
* a Doctrine_Record is in clean state when all of its properties are loaded from the database
|
||||
* a Doctrine_Entity is in clean state when all of its properties are loaded from the database
|
||||
* and none of its properties are changed
|
||||
*/
|
||||
const STATE_CLEAN = 3;
|
||||
|
||||
/**
|
||||
* PROXY STATE
|
||||
* a Doctrine_Record is in proxy state when its properties are not fully loaded
|
||||
* a Doctrine_Entity is in proxy state when its properties are not fully loaded
|
||||
*/
|
||||
const STATE_PROXY = 4;
|
||||
|
||||
/**
|
||||
* NEW TCLEAN
|
||||
* a Doctrine_Record is in transient clean state when it is created and none of its fields are modified
|
||||
* a Doctrine_Entity is in transient clean state when it is created and none of its fields are modified
|
||||
*/
|
||||
const STATE_TCLEAN = 5;
|
||||
|
||||
/**
|
||||
* LOCKED STATE
|
||||
* a Doctrine_Record is temporarily locked during deletes and saves
|
||||
* a Doctrine_Entity is temporarily locked during deletes and saves
|
||||
*
|
||||
* This state is used internally to ensure that circular deletes
|
||||
* and saves will not cause infinite loops
|
||||
@ -119,7 +119,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
protected $_class;
|
||||
|
||||
/**
|
||||
*
|
||||
* The name of the Entity.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_entityName;
|
||||
|
||||
@ -146,7 +148,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
/**
|
||||
* The values array, aggregate values and such are mapped into this array.
|
||||
*
|
||||
* @var array
|
||||
* @var array
|
||||
* @todo Remove.
|
||||
*/
|
||||
protected $_values = array();
|
||||
|
||||
@ -206,15 +209,19 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
* @throws Doctrine_Connection_Exception if object is created using the new operator and there are no
|
||||
* open connections
|
||||
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow
|
||||
* @todo Remove all parameters.
|
||||
*/
|
||||
public function __construct($isNewEntry = true, array $data = array())
|
||||
{
|
||||
$this->_entityName = get_class($this);
|
||||
$this->_em = Doctrine_Manager::getInstance()->getCurrentConnection();
|
||||
// future: $this->_em = Doctrine_EntityManager::getManagerForEntity($this->_entityName);
|
||||
$this->_class = $this->_em->getClassMetadata($this->_entityName);
|
||||
|
||||
$this->_oid = self::$_index++;
|
||||
|
||||
|
||||
// The following code inits data, id and state
|
||||
|
||||
// get the data array
|
||||
$this->_data = $data;
|
||||
|
||||
@ -227,24 +234,25 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
|
||||
if ($isNewEntry) {
|
||||
if ($count > count($this->_values)) {
|
||||
$this->_state = Doctrine_Record::STATE_TDIRTY;
|
||||
$this->_state = Doctrine_Entity::STATE_TDIRTY;
|
||||
} else {
|
||||
$this->_state = Doctrine_Record::STATE_TCLEAN;
|
||||
$this->_state = Doctrine_Entity::STATE_TCLEAN;
|
||||
}
|
||||
|
||||
// set the default values for this record
|
||||
$this->assignDefaultValues();
|
||||
} else {
|
||||
// TODO: registerClean() on UnitOfWork
|
||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||
$this->_state = Doctrine_Entity::STATE_CLEAN;
|
||||
if ($count < $this->_class->getColumnCount()) {
|
||||
$this->_state = Doctrine_Record::STATE_PROXY;
|
||||
$this->_state = Doctrine_Entity::STATE_PROXY;
|
||||
}
|
||||
}
|
||||
//--
|
||||
|
||||
self::$_useAutoAccessorOverride = false; // @todo read from attribute the first time
|
||||
$this->_em->manage($this);
|
||||
$this->construct();
|
||||
$this->_em->manage($this); // @todo Remove
|
||||
$this->construct(); // @todo Remove
|
||||
}
|
||||
|
||||
/**
|
||||
@ -450,7 +458,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
{
|
||||
if ($stack !== null) {
|
||||
if ( ! ($stack instanceof Doctrine_Validator_ErrorStack)) {
|
||||
throw new Doctrine_Record_Exception('Argument should be an instance of Doctrine_Validator_ErrorStack.');
|
||||
throw new Doctrine_Entity_Exception('Argument should be an instance of Doctrine_Validator_ErrorStack.');
|
||||
}
|
||||
$this->_errorStack = $stack;
|
||||
} else {
|
||||
@ -464,7 +472,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*
|
||||
* @param boolean $overwrite whether or not to overwrite the already set values
|
||||
* @return boolean
|
||||
* @todo Maybe better placed in the Mapper?
|
||||
* @todo Job of EntityManager.
|
||||
*/
|
||||
public function assignDefaultValues($overwrite = false)
|
||||
{
|
||||
@ -481,7 +489,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
if ($value === Doctrine_Null::$INSTANCE || $overwrite) {
|
||||
$this->_data[$column] = $default;
|
||||
$this->_modified[] = $column;
|
||||
$this->_state = Doctrine_Record::STATE_TDIRTY;
|
||||
$this->_state = Doctrine_Entity::STATE_TDIRTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -494,7 +502,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*
|
||||
* @param array $data data array to be cleaned
|
||||
* @return array $tmp values cleaned from data
|
||||
* @todo Maybe better placed in the Mapper?
|
||||
* @todo Remove. Should not be necessary. Slows down instantiation.
|
||||
*/
|
||||
public function cleanData(&$data)
|
||||
{
|
||||
@ -601,7 +609,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
$this->_data = array_merge($this->_data, $this->_id);
|
||||
|
||||
foreach ($this->_data as $k => $v) {
|
||||
if ($v instanceof Doctrine_Record && $this->_class->getTypeOf($k) != 'object') {
|
||||
if ($v instanceof Doctrine_Entity && $this->_class->getTypeOf($k) != 'object') {
|
||||
unset($vars['_data'][$k]);
|
||||
} else if ($v === Doctrine_Null::$INSTANCE) {
|
||||
unset($vars['_data'][$k]);
|
||||
@ -632,7 +640,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
* Reconstructs the entity from it's serialized form.
|
||||
* This method is automatically called everytime the entity is unserialized.
|
||||
*
|
||||
* @param string $serialized Doctrine_Record as serialized string
|
||||
* @param string $serialized Doctrine_Entity as serialized string
|
||||
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow
|
||||
* @return void
|
||||
*/
|
||||
@ -687,7 +695,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
* returns / assigns the state of this record
|
||||
*
|
||||
* @param integer|string $state if set, this method tries to set the record state to $state
|
||||
* @see Doctrine_Record::STATE_* constants
|
||||
* @see Doctrine_Entity::STATE_* constants
|
||||
*
|
||||
* @throws Doctrine_Record_State_Exception if trying to set an unknown state
|
||||
* @return null|integer
|
||||
@ -707,7 +715,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
} else if (is_string($state)) {
|
||||
$upper = strtoupper($state);
|
||||
|
||||
$const = 'Doctrine_Record::STATE_' . $upper;
|
||||
$const = 'Doctrine_Entity::STATE_' . $upper;
|
||||
if (defined($const)) {
|
||||
$this->_state = constant($const);
|
||||
} else {
|
||||
@ -715,8 +723,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_state === Doctrine_Record::STATE_TCLEAN ||
|
||||
$this->_state === Doctrine_Record::STATE_CLEAN) {
|
||||
if ($this->_state === Doctrine_Entity::STATE_TCLEAN ||
|
||||
$this->_state === Doctrine_Entity::STATE_CLEAN) {
|
||||
$this->_modified = array();
|
||||
}
|
||||
|
||||
@ -735,8 +743,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
* @throws Doctrine_Record_Exception When the refresh operation fails (when the database row
|
||||
* this record represents does not exist anymore)
|
||||
* @return boolean
|
||||
* @todo Logic is better placed in the Mapper. Just forward to the mapper.
|
||||
* @todo ActiveRecord method.
|
||||
* @todo Implementation to EntityManager.
|
||||
* @todo ActiveEntity method.
|
||||
*/
|
||||
public function refresh($deep = false)
|
||||
{
|
||||
@ -773,7 +781,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
|
||||
$this->_extractIdentifier();
|
||||
|
||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||
$this->_state = Doctrine_Entity::STATE_CLEAN;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -785,9 +793,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
* @param string $name name of a related component.
|
||||
* if set, this method only refreshes the specified related component
|
||||
*
|
||||
* @return Doctrine_Record this object
|
||||
* @todo Logic is better placed in the Mapper. Just forward to the mapper.
|
||||
* @todo ActiveRecord method.
|
||||
* @return Doctrine_Entity this object
|
||||
* @todo Implementation to EntityManager.
|
||||
* @todo ActiveEntity method.
|
||||
*/
|
||||
public function refreshRelated($name = null)
|
||||
{
|
||||
@ -823,7 +831,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @todo Remove.
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
@ -831,25 +839,136 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
}
|
||||
|
||||
/**
|
||||
* rawGet
|
||||
* returns the value of a property, if the property is not yet loaded
|
||||
* this method does NOT load it
|
||||
* Gets the value of a field (regular field or reference).
|
||||
* If the property is not yet loaded this method does NOT load it.
|
||||
*
|
||||
* NOTE: Use of this method from outside the scope of an extending class
|
||||
* is strongly discouraged.
|
||||
*
|
||||
* @param $name name of the property
|
||||
* @throws Doctrine_Record_Exception if trying to get an unknown property
|
||||
* @throws Doctrine_Entity_Exception if trying to get an unknown field
|
||||
* @return mixed
|
||||
*/
|
||||
public function rawGet($fieldName)
|
||||
{
|
||||
if ( ! isset($this->_data[$fieldName])) {
|
||||
throw new Doctrine_Record_Exception('Unknown property '. $fieldName);
|
||||
if (isset($this->_data[$fieldName])) {
|
||||
return $this->rawGetField($fieldName);
|
||||
} else if (isset($this->_references[$fieldName])) {
|
||||
return $this->rawGetReference($fieldName);
|
||||
} else {
|
||||
throw Doctrine_Entity_Exception::unknownField($fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a field.
|
||||
*
|
||||
* NOTE: Use of this method from outside the scope of an extending class
|
||||
* is strongly discouraged. This method does NOT check whether the field
|
||||
* exists.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return mixed
|
||||
*/
|
||||
public function rawGetField($fieldName)
|
||||
{
|
||||
if ($this->_data[$fieldName] === Doctrine_Null::$INSTANCE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->_data[$fieldName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of a field.
|
||||
*
|
||||
* NOTE: Use of this method from outside the scope of an extending class
|
||||
* is strongly discouraged. This method does NOT check whether the field
|
||||
* exists.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function rawSetField($fieldName, $value)
|
||||
{
|
||||
$this->_data[$fieldName] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference to another Entity.
|
||||
*
|
||||
* NOTE: Use of this method from outside the scope of an extending class
|
||||
* is strongly discouraged. This method does NOT check whether the reference
|
||||
* exists.
|
||||
*
|
||||
* @param unknown_type $fieldName
|
||||
*/
|
||||
public function rawGetReference($fieldName)
|
||||
{
|
||||
if ($this->_references[$fieldName] === Doctrine_Null::$INSTANCE) {
|
||||
return null;
|
||||
}
|
||||
return $this->_references[$fieldName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a reference to another Entity.
|
||||
*
|
||||
* NOTE: Use of this method from outside the scope of an extending class
|
||||
* is strongly discouraged.
|
||||
*
|
||||
* @param unknown_type $fieldName
|
||||
* @param unknown_type $value
|
||||
* @todo Refactor. What about composite keys?
|
||||
*/
|
||||
public function rawSetReference($name, $value)
|
||||
{
|
||||
if ($value === Doctrine_Null::$INSTANCE) {
|
||||
$this->_references[$name] = $value;
|
||||
return;
|
||||
}
|
||||
|
||||
$rel = $this->_class->getRelation($name);
|
||||
|
||||
// one-to-many or one-to-one relation
|
||||
if ($rel instanceof Doctrine_Relation_ForeignKey ||
|
||||
$rel instanceof Doctrine_Relation_LocalKey) {
|
||||
if ( ! $rel->isOneToOne()) {
|
||||
// one-to-many relation found
|
||||
if ( ! $value instanceof Doctrine_Collection) {
|
||||
throw Doctrine_Entity_Exception::invalidValueForOneToManyReference();
|
||||
}
|
||||
if (isset($this->_references[$name])) {
|
||||
$this->_references[$name]->setData($value->getData());
|
||||
return $this;
|
||||
}
|
||||
} else {
|
||||
$relatedTable = $value->getTable();
|
||||
$foreignFieldName = $rel->getForeignFieldName();
|
||||
$localFieldName = $rel->getLocalFieldName();
|
||||
|
||||
// one-to-one relation found
|
||||
if ( ! ($value instanceof Doctrine_Entity)) {
|
||||
throw Doctrine_Entity_Exception::invalidValueForOneToOneReference();
|
||||
}
|
||||
if ($rel instanceof Doctrine_Relation_LocalKey) {
|
||||
$idFieldNames = $value->getTable()->getIdentifier();
|
||||
if ( ! empty($foreignFieldName) && $foreignFieldName != $idFieldNames[0]) {
|
||||
$this->set($localFieldName, $value->rawGet($foreignFieldName), false);
|
||||
} else {
|
||||
$this->set($localFieldName, $value, false);
|
||||
}
|
||||
} else {
|
||||
$value->set($foreignFieldName, $this, false);
|
||||
}
|
||||
}
|
||||
} else if ($rel instanceof Doctrine_Relation_Association) {
|
||||
if ( ! ($value instanceof Doctrine_Collection)) {
|
||||
throw Doctrine_Entity_Exception::invalidValueForManyToManyReference();
|
||||
}
|
||||
}
|
||||
|
||||
$this->_references[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* load
|
||||
@ -860,10 +979,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
// only load the data from database if the Doctrine_Record is in proxy state
|
||||
if ($this->_state == Doctrine_Record::STATE_PROXY) {
|
||||
// only load the data from database if the Doctrine_Entity is in proxy state
|
||||
if ($this->_state == Doctrine_Entity::STATE_PROXY) {
|
||||
$this->refresh();
|
||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||
$this->_state = Doctrine_Entity::STATE_CLEAN;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -966,7 +1085,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
|
||||
/**
|
||||
* set
|
||||
* method for altering properties and Doctrine_Record references
|
||||
* method for altering properties and Doctrine_Entity references
|
||||
* if the load parameter is set to false this method will not try to load uninitialized record data
|
||||
*
|
||||
* @param mixed $name name of the property or reference
|
||||
@ -976,12 +1095,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
* @throws Doctrine_Record_Exception if trying to set a value for unknown property / related component
|
||||
* @throws Doctrine_Record_Exception if trying to set a value of wrong type for related component
|
||||
*
|
||||
* @return Doctrine_Record
|
||||
* @return Doctrine_Entity
|
||||
*/
|
||||
public function set($fieldName, $value, $load = true)
|
||||
{
|
||||
if (isset($this->_data[$fieldName])) {
|
||||
if ($value instanceof Doctrine_Record) {
|
||||
if ($value instanceof Doctrine_Entity) {
|
||||
$type = $this->_class->getTypeOf($fieldName);
|
||||
// FIXME: composite key support
|
||||
$ids = $value->identifier();
|
||||
@ -1012,17 +1131,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
}
|
||||
|
||||
switch ($this->_state) {
|
||||
case Doctrine_Record::STATE_CLEAN:
|
||||
$this->_state = Doctrine_Record::STATE_DIRTY;
|
||||
case Doctrine_Entity::STATE_CLEAN:
|
||||
$this->_state = Doctrine_Entity::STATE_DIRTY;
|
||||
break;
|
||||
case Doctrine_Record::STATE_TCLEAN:
|
||||
$this->_state = Doctrine_Record::STATE_TDIRTY;
|
||||
case Doctrine_Entity::STATE_TCLEAN:
|
||||
$this->_state = Doctrine_Entity::STATE_TDIRTY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$this->_coreSetRelated($fieldName, $value);
|
||||
$this->rawSetReference($fieldName, $value);
|
||||
} catch (Doctrine_Relation_Exception $e) {
|
||||
//echo $e->getTraceAsString();
|
||||
//echo "<br/><br/>";
|
||||
@ -1035,67 +1154,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a related component.
|
||||
* @todo Refactor. What about composite keys?
|
||||
*/
|
||||
private function _coreSetRelated($name, $value)
|
||||
{
|
||||
if ($value === Doctrine_Null::$INSTANCE) {
|
||||
$this->_references[$name] = $value;
|
||||
return;
|
||||
}
|
||||
|
||||
$rel = $this->_class->getRelation($name);
|
||||
|
||||
// one-to-many or one-to-one relation
|
||||
if ($rel instanceof Doctrine_Relation_ForeignKey ||
|
||||
$rel instanceof Doctrine_Relation_LocalKey) {
|
||||
if ( ! $rel->isOneToOne()) {
|
||||
// one-to-many relation found
|
||||
if ( ! $value instanceof Doctrine_Collection) {
|
||||
throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second"
|
||||
. " argument should be an instance of Doctrine_Collection when"
|
||||
. " setting one-to-many references.");
|
||||
}
|
||||
if (isset($this->_references[$name])) {
|
||||
$this->_references[$name]->setData($value->getData());
|
||||
return $this;
|
||||
}
|
||||
} else {
|
||||
if ($value !== Doctrine_Null::$INSTANCE) {
|
||||
$relatedTable = $value->getTable();
|
||||
$foreignFieldName = $rel->getForeignFieldName();
|
||||
$localFieldName = $rel->getLocalFieldName();
|
||||
|
||||
// one-to-one relation found
|
||||
if ( ! ($value instanceof Doctrine_Record)) {
|
||||
throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(),"
|
||||
. " second argument should be an instance of Doctrine_Record"
|
||||
. " or Doctrine_Null when setting one-to-one references.");
|
||||
}
|
||||
if ($rel instanceof Doctrine_Relation_LocalKey) {
|
||||
$idFieldNames = $value->getTable()->getIdentifier();
|
||||
if ( ! empty($foreignFieldName) && $foreignFieldName != $idFieldNames[0]) {
|
||||
$this->set($localFieldName, $value->rawGet($foreignFieldName), false);
|
||||
} else {
|
||||
$this->set($localFieldName, $value, false);
|
||||
}
|
||||
} else {
|
||||
$value->set($foreignFieldName, $this, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($rel instanceof Doctrine_Relation_Association) {
|
||||
// join table relation found
|
||||
if ( ! ($value instanceof Doctrine_Collection)) {
|
||||
throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting many-to-many references.");
|
||||
}
|
||||
}
|
||||
|
||||
$this->_references[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* contains
|
||||
*
|
||||
@ -1132,7 +1190,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
if (isset($this->_data[$fieldName])) {
|
||||
$this->_data[$fieldName] = array();
|
||||
} else if (isset($this->_references[$fieldName])) {
|
||||
if ($this->_references[$fieldName] instanceof Doctrine_Record) {
|
||||
if ($this->_references[$fieldName] instanceof Doctrine_Entity) {
|
||||
// todo: delete related record when saving $this
|
||||
$this->_references[$fieldName] = Doctrine_Null::$INSTANCE;
|
||||
} else if ($this->_references[$fieldName] instanceof Doctrine_Collection) {
|
||||
@ -1157,7 +1215,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
|
||||
/**
|
||||
* Tries to save the object and all its related objects.
|
||||
* In contrast to Doctrine_Record::save(), this method does not
|
||||
* In contrast to Doctrine_Entity::save(), this method does not
|
||||
* throw an exception when validation fails but returns TRUE on
|
||||
* success or FALSE on failure.
|
||||
*
|
||||
@ -1269,7 +1327,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
$dataSet[$field] = $this->_class->enumIndex($field, $this->_data[$field]);
|
||||
break;
|
||||
default:
|
||||
if ($this->_data[$field] instanceof Doctrine_Record) {
|
||||
if ($this->_data[$field] instanceof Doctrine_Entity) {
|
||||
// FIXME: composite key support
|
||||
$ids = $this->_data[$field]->identifier();
|
||||
$id = count($ids) > 0 ? array_pop($ids) : null;
|
||||
@ -1353,9 +1411,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
}
|
||||
}
|
||||
|
||||
// [FIX] Prevent mapped Doctrine_Records from being displayed fully
|
||||
// [FIX] Prevent mapped Doctrine_Entitys from being displayed fully
|
||||
foreach ($this->_values as $key => $value) {
|
||||
if ($value instanceof Doctrine_Record) {
|
||||
if ($value instanceof Doctrine_Entity) {
|
||||
$a[$key] = $value->toArray($deep, $prefixKey);
|
||||
} else {
|
||||
$a[$key] = $value;
|
||||
@ -1410,14 +1468,14 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
|
||||
/**
|
||||
* synchronizeFromArray
|
||||
* synchronizes a Doctrine_Record and its relations with data from an array
|
||||
* synchronizes a Doctrine_Entity and its relations with data from an array
|
||||
*
|
||||
* it expects an array representation of a Doctrine_Record similar to the return
|
||||
* it expects an array representation of a Doctrine_Entity similar to the return
|
||||
* value of the toArray() method. If the array contains relations it will create
|
||||
* those that don't exist, update the ones that do, and delete the ones missing
|
||||
* on the array but available on the Doctrine_Record
|
||||
* on the array but available on the Doctrine_Entity
|
||||
*
|
||||
* @param array $array representation of a Doctrine_Record
|
||||
* @param array $array representation of a Doctrine_Entity
|
||||
* @todo ActiveRecord method.
|
||||
*/
|
||||
public function synchronizeFromArray(array $array)
|
||||
@ -1480,8 +1538,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*/
|
||||
public function exists()
|
||||
{
|
||||
return ($this->_state !== Doctrine_Record::STATE_TCLEAN &&
|
||||
$this->_state !== Doctrine_Record::STATE_TDIRTY);
|
||||
return ($this->_state !== Doctrine_Entity::STATE_TCLEAN &&
|
||||
$this->_state !== Doctrine_Entity::STATE_TDIRTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1513,8 +1571,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*/
|
||||
public function isDirty()
|
||||
{
|
||||
return ($this->_state === Doctrine_Record::STATE_DIRTY ||
|
||||
$this->_state === Doctrine_Record::STATE_TDIRTY);
|
||||
return ($this->_state === Doctrine_Entity::STATE_DIRTY ||
|
||||
$this->_state === Doctrine_Entity::STATE_TDIRTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1526,12 +1584,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*/
|
||||
public function isModified()
|
||||
{
|
||||
return ($this->_state === Doctrine_Record::STATE_DIRTY ||
|
||||
$this->_state === Doctrine_Record::STATE_TDIRTY);
|
||||
return ($this->_state === Doctrine_Entity::STATE_DIRTY ||
|
||||
$this->_state === Doctrine_Entity::STATE_TDIRTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* method for checking existence of properties and Doctrine_Record references
|
||||
* method for checking existence of properties and Doctrine_Entity references
|
||||
*
|
||||
* @param mixed $name name of the property or reference
|
||||
* @return boolean
|
||||
@ -1572,7 +1630,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
/**
|
||||
* Creates a copy of the entity.
|
||||
*
|
||||
* @return Doctrine_Record
|
||||
* @return Doctrine_Entity
|
||||
* @todo ActiveRecord method. Implementation to EntityManager.
|
||||
*/
|
||||
public function copy($deep = true)
|
||||
@ -1621,11 +1679,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
if ($id === false) {
|
||||
$this->_id = array();
|
||||
$this->_data = $this->cleanData($this->_data);
|
||||
$this->_state = Doctrine_Record::STATE_TCLEAN;
|
||||
$this->_state = Doctrine_Entity::STATE_TCLEAN;
|
||||
$this->_modified = array();
|
||||
} else if ($id === true) {
|
||||
$this->_extractIdentifier(true);
|
||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||
$this->_state = Doctrine_Entity::STATE_CLEAN;
|
||||
$this->_modified = array();
|
||||
} else {
|
||||
if (is_array($id)) {
|
||||
@ -1639,7 +1697,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
$this->_id[$name] = $id;
|
||||
$this->_data[$name] = $id;
|
||||
}
|
||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||
$this->_state = Doctrine_Entity::STATE_CLEAN;
|
||||
$this->_modified = array();
|
||||
}
|
||||
}
|
||||
@ -1731,7 +1789,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
* @param string|array $callback valid callback
|
||||
* @param string $column column name
|
||||
* @param mixed arg1 ... argN optional callback arguments
|
||||
* @return Doctrine_Record
|
||||
* @return Doctrine_Entity
|
||||
* @todo Really needed/used? If not, remove.
|
||||
* @todo ActiveRecord method. (if at all)
|
||||
*/
|
||||
@ -1779,7 +1837,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*
|
||||
* @throws Doctrine_Record_Exception if given version does not exist
|
||||
* @param integer $version an integer > 1
|
||||
* @return Doctrine_Record this object
|
||||
* @return Doctrine_Entity this object
|
||||
* @todo Should go to the Versionable plugin.
|
||||
*/
|
||||
public function revert($version)
|
||||
@ -1813,7 +1871,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*
|
||||
* @param string $alias related component alias
|
||||
* @param array $ids the identifiers of the related records
|
||||
* @return Doctrine_Record this object
|
||||
* @return Doctrine_Entity this object
|
||||
* @todo ActiveRecord method.
|
||||
*/
|
||||
public function unlink($alias, $ids = array())
|
||||
@ -1868,7 +1926,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*
|
||||
* @param string $alias related component alias
|
||||
* @param array $ids the identifiers of the related records
|
||||
* @return Doctrine_Record this object
|
||||
* @return Doctrine_Entity this object
|
||||
* @todo ActiveRecord method.
|
||||
*/
|
||||
public function link($alias, array $ids)
|
||||
@ -2001,8 +2059,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
return $this->_class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
public function getEntityManager()
|
||||
{
|
||||
if ( ! $this->_em) {
|
||||
$this->_em = Doctrine_Manager::getInstance()->getCurrentConnection();
|
||||
// future: $this->_em = Doctrine_EntityManager::getManagerForEntity($this->_entityName);
|
||||
}
|
||||
return $this->_em;
|
||||
}
|
||||
|
28
lib/Doctrine/Entity/Exception.php
Normal file
28
lib/Doctrine/Entity/Exception.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
class Doctrine_Entity_Exception extends Doctrine_Exception
|
||||
{
|
||||
public static function unknownField($field)
|
||||
{
|
||||
return new self("Undefined field: '$field'.");
|
||||
}
|
||||
|
||||
public static function invalidValueForOneToManyReference()
|
||||
{
|
||||
return new self("Invalid value. The value of a reference in a OneToMany "
|
||||
. "association must be a Collection.");
|
||||
}
|
||||
|
||||
public static function invalidValueForOneToOneReference()
|
||||
{
|
||||
return new self("Invalid value. The value of a reference in a OneToOne "
|
||||
. "association must be an Entity.");
|
||||
}
|
||||
|
||||
public static function invalidValueForManyToManyReference()
|
||||
{
|
||||
return new self("Invalid value. The value of a reference in a ManyToMany "
|
||||
. "association must be a Collection.");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -63,11 +63,9 @@ class Doctrine_EntityRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* clear
|
||||
* clears the first level cache (identityMap)
|
||||
* Clears the repository, causing all managed entities to become detached.
|
||||
*
|
||||
* @return void
|
||||
* @todo what about a more descriptive name? clearIdentityMap?
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
@ -77,9 +75,9 @@ class Doctrine_EntityRepository
|
||||
/**
|
||||
* Finds an entity by its primary key.
|
||||
*
|
||||
* @param $id database row id
|
||||
* @param int $hydrationMode Doctrine::HYDRATE_ARRAY or Doctrine::HYDRATE_RECORD
|
||||
* @return mixed Array or Doctrine_Record or false if no result
|
||||
* @param $id The identifier.
|
||||
* @param int $hydrationMode The hydration mode to use.
|
||||
* @return mixed Array or Doctrine_Entity or false if no result
|
||||
* @todo Remove. Move to EntityRepository.
|
||||
*/
|
||||
public function find($id, $hydrationMode = null)
|
||||
|
@ -96,12 +96,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
|
||||
/**
|
||||
* onLoad
|
||||
* an event invoked when Doctrine_Record is being loaded from database
|
||||
* an event invoked when Doctrine_Entity is being loaded from database
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return void
|
||||
*/
|
||||
public function onLoad(Doctrine_Record $record)
|
||||
public function onLoad(Doctrine_Entity $record)
|
||||
{
|
||||
foreach ($this->_listeners as $listener) {
|
||||
$listener->onLoad($record);
|
||||
@ -110,13 +110,13 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
|
||||
/**
|
||||
* onPreLoad
|
||||
* an event invoked when Doctrine_Record is being loaded
|
||||
* an event invoked when Doctrine_Entity is being loaded
|
||||
* from database but not yet initialized
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return void
|
||||
*/
|
||||
public function onPreLoad(Doctrine_Record $record)
|
||||
public function onPreLoad(Doctrine_Entity $record)
|
||||
{
|
||||
foreach ($this->_listeners as $listener) {
|
||||
$listener->onPreLoad($record);
|
||||
@ -125,12 +125,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
|
||||
/**
|
||||
* onSleep
|
||||
* an event invoked when Doctrine_Record is serialized
|
||||
* an event invoked when Doctrine_Entity is serialized
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return void
|
||||
*/
|
||||
public function onSleep(Doctrine_Record $record)
|
||||
public function onSleep(Doctrine_Entity $record)
|
||||
{
|
||||
foreach ($this->_listeners as $listener) {
|
||||
$listener->onSleep($record);
|
||||
@ -139,12 +139,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
||||
|
||||
/**
|
||||
* onWakeUp
|
||||
* an event invoked when Doctrine_Record is unserialized
|
||||
* an event invoked when Doctrine_Entity is unserialized
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return void
|
||||
*/
|
||||
public function onWakeUp(Doctrine_Record $record)
|
||||
public function onWakeUp(Doctrine_Entity $record)
|
||||
{
|
||||
foreach ($this->_listeners as $listener) {
|
||||
$listener->onWakeUp($record);
|
||||
|
@ -1030,13 +1030,13 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
||||
|
||||
/**
|
||||
* exportSchema
|
||||
* method for exporting Doctrine_Record classes to a schema
|
||||
* method for exporting Doctrine_Entity classes to a schema
|
||||
*
|
||||
* if the directory parameter is given this method first iterates
|
||||
* recursively trhough the given directory in order to find any model classes
|
||||
*
|
||||
* Then it iterates through all declared classes and creates tables for the ones
|
||||
* that extend Doctrine_Record and are not abstract classes
|
||||
* that extend Doctrine_Entity and are not abstract classes
|
||||
*
|
||||
* @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS
|
||||
* occurred during the create table operation
|
||||
@ -1060,7 +1060,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
||||
* FIXME: This method is a big huge hack. The sql needs to be executed in the correct order. I have some stupid logic to
|
||||
* make sure they are in the right order.
|
||||
*
|
||||
* method for exporting Doctrine_Record classes to a schema
|
||||
* method for exporting Doctrine_Entity classes to a schema
|
||||
*
|
||||
* @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS
|
||||
* occurred during the create table operation
|
||||
@ -1133,7 +1133,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
||||
|
||||
/**
|
||||
* exportClassesSql
|
||||
* method for exporting Doctrine_Record classes to a schema
|
||||
* method for exporting Doctrine_Entity classes to a schema
|
||||
*
|
||||
* @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS
|
||||
* occurred during the create table operation
|
||||
@ -1244,13 +1244,13 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
||||
|
||||
/**
|
||||
* exportSql
|
||||
* returns the sql for exporting Doctrine_Record classes to a schema
|
||||
* returns the sql for exporting Doctrine_Entity classes to a schema
|
||||
*
|
||||
* if the directory parameter is given this method first iterates
|
||||
* recursively trhough the given directory in order to find any model classes
|
||||
*
|
||||
* Then it iterates through all declared classes and creates tables for the ones
|
||||
* that extend Doctrine_Record and are not abstract classes
|
||||
* that extend Doctrine_Entity and are not abstract classes
|
||||
*
|
||||
* @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS
|
||||
* occurred during the create table operation
|
||||
|
@ -52,7 +52,7 @@ class Doctrine_Export_Schema
|
||||
|
||||
$array = array();
|
||||
|
||||
$parent = new ReflectionClass('Doctrine_Record');
|
||||
$parent = new ReflectionClass('Doctrine_Entity');
|
||||
|
||||
$sql = array();
|
||||
$fks = array();
|
||||
|
@ -30,7 +30,7 @@
|
||||
* @link www.phpdoctrine.org
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_File extends Doctrine_Record
|
||||
class Doctrine_File extends Doctrine_Entity
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
|
@ -30,7 +30,7 @@
|
||||
* @link www.phpdoctrine.org
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_File_Index extends Doctrine_Record
|
||||
class Doctrine_File_Index extends Doctrine_Entity
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
|
@ -58,22 +58,27 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
|
||||
* )
|
||||
* @return mixed The created object/array graph.
|
||||
*/
|
||||
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null)
|
||||
public function hydrateResultSet($parserResult)
|
||||
{
|
||||
if ($hydrationMode === null) {
|
||||
if ($parserResult->getHydrationMode() === null) {
|
||||
$hydrationMode = $this->_hydrationMode;
|
||||
} else {
|
||||
$hydrationMode = $parserResult->getHydrationMode();
|
||||
}
|
||||
|
||||
$stmt = $parserResult->getDatabaseStatement();
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_NONE) {
|
||||
return $stmt->fetchAll(PDO::FETCH_NUM);
|
||||
}
|
||||
|
||||
$this->_tableAliases = $tableAliases;
|
||||
$this->_tableAliases = $parserResult->getTableToClassAliasMap();
|
||||
$this->_queryComponents = $parserResult->getQueryComponents();
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
|
||||
$driver = new Doctrine_Hydrator_ArrayDriver();
|
||||
} else {
|
||||
$driver = new Doctrine_Hydrator_RecordDriver();
|
||||
$driver = new Doctrine_Hydrator_RecordDriver($this->_em);
|
||||
}
|
||||
|
||||
$event = new Doctrine_Event(null, Doctrine_Event::HYDRATE, null);
|
||||
@ -294,7 +299,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
|
||||
end($coll);
|
||||
$prev[$dqlAlias] =& $coll[key($coll)];
|
||||
}
|
||||
} else if ($coll instanceof Doctrine_Record) {
|
||||
} else if ($coll instanceof Doctrine_Entity) {
|
||||
$prev[$dqlAlias] = $coll;
|
||||
} else if (count($coll) > 0) {
|
||||
$prev[$dqlAlias] = $coll->getLast();
|
||||
|
@ -55,14 +55,17 @@ abstract class Doctrine_Hydrator_Abstract
|
||||
protected $_hydrationMode = Doctrine::HYDRATE_RECORD;
|
||||
|
||||
protected $_nullObject;
|
||||
|
||||
protected $_em;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param Doctrine_Connection|null $connection
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Doctrine_Connection $em)
|
||||
{
|
||||
$this->_em = $em;
|
||||
$this->_nullObject = Doctrine_Null::$INSTANCE;
|
||||
}
|
||||
|
||||
@ -156,6 +159,6 @@ abstract class Doctrine_Hydrator_Abstract
|
||||
* @param mixed $stmt
|
||||
* @return array
|
||||
*/
|
||||
abstract public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null);
|
||||
abstract public function hydrateResultSet($parserResult);
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
*/
|
||||
class Doctrine_Hydrator_ArrayDriver
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -73,6 +74,52 @@ class Doctrine_Hydrator_ArrayDriver
|
||||
}
|
||||
}
|
||||
|
||||
public function addRelatedIndexedElement(array &$entity1, $property, array &$entity2,
|
||||
$indexField)
|
||||
{
|
||||
$entity1[$property][$entity2[$indexField]] = $entity2;
|
||||
}
|
||||
|
||||
public function addRelatedElement(array &$entity1, $property, array &$entity2)
|
||||
{
|
||||
$entity1[$property][] = $entity2;
|
||||
}
|
||||
|
||||
public function setRelatedElement(array &$entity1, $property, &$entity2)
|
||||
{
|
||||
$entity1[$property] = $entity2;
|
||||
}
|
||||
|
||||
public function isIndexKeyInUse(array &$entity, $assocField, $indexField)
|
||||
{
|
||||
return isset($entity[$assocField][$indexField]);
|
||||
}
|
||||
|
||||
public function isFieldSet(array &$entity, $field)
|
||||
{
|
||||
return isset($entity[$field]);
|
||||
}
|
||||
|
||||
public function getFieldValue(array &$entity, $field)
|
||||
{
|
||||
return $entity[$field];
|
||||
}
|
||||
|
||||
public function &getReferenceValue(array &$entity, $field)
|
||||
{
|
||||
return $entity[$field];
|
||||
}
|
||||
|
||||
public function addElementToIndexedCollection(array &$coll, array &$entity, $keyField)
|
||||
{
|
||||
$coll[$entity[$keyField]] = $entity;
|
||||
}
|
||||
|
||||
public function addElementToCollection(array &$coll, array &$entity)
|
||||
{
|
||||
$coll[] = $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -36,16 +36,17 @@ class Doctrine_Hydrator_RecordDriver
|
||||
{
|
||||
/** Collections initialized by the driver */
|
||||
protected $_collections = array();
|
||||
/** Mappers */
|
||||
protected $_mappers = array();
|
||||
/** Memory for initialized relations */
|
||||
private $_initializedRelations = array();
|
||||
/** Null object */
|
||||
private $_nullObject;
|
||||
/** The EntityManager */
|
||||
private $_em;
|
||||
|
||||
public function __construct()
|
||||
public function __construct(Doctrine_Connection $em)
|
||||
{
|
||||
$this->_nullObject = Doctrine_Null::$INSTANCE;
|
||||
$this->_em = $em;
|
||||
}
|
||||
|
||||
public function getElementCollection($component)
|
||||
@ -68,15 +69,15 @@ class Doctrine_Hydrator_RecordDriver
|
||||
}
|
||||
}
|
||||
|
||||
public function initRelatedCollection(Doctrine_Record $record, $name)
|
||||
public function initRelatedCollection(Doctrine_Entity $entity, $name)
|
||||
{
|
||||
if ( ! isset($this->_initializedRelations[$record->getOid()][$name])) {
|
||||
$relation = $record->getClassMetadata()->getRelation($name);
|
||||
if ( ! isset($this->_initializedRelations[$entity->getOid()][$name])) {
|
||||
$relation = $entity->getClassMetadata()->getRelation($name);
|
||||
$relatedClass = $relation->getTable();
|
||||
$coll = $this->getElementCollection($relatedClass->getClassName());
|
||||
$coll->setReference($record, $relation);
|
||||
$record[$name] = $coll;
|
||||
$this->_initializedRelations[$record->getOid()][$name] = true;
|
||||
$coll->setReference($entity, $relation);
|
||||
$entity->rawSetReference($name, $coll);
|
||||
$this->_initializedRelations[$entity->getOid()][$name] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,14 +93,54 @@ class Doctrine_Hydrator_RecordDriver
|
||||
|
||||
public function getElement(array $data, $className)
|
||||
{
|
||||
$className = $this->_getClassnameToReturn($data, $className);
|
||||
if ( ! isset($this->_mappers[$className])) {
|
||||
$this->_mappers[$className] = Doctrine_Manager::getInstance()->getMapper($className);
|
||||
}
|
||||
|
||||
$record = $this->_mappers[$className]->getRecord($data);
|
||||
|
||||
return $record;
|
||||
return $this->_em->createEntity2($className, $data);
|
||||
}
|
||||
|
||||
public function addRelatedIndexedElement(Doctrine_Entity $entity1, $property,
|
||||
Doctrine_Entity $entity2, $indexField)
|
||||
{
|
||||
$entity1->rawGetReference($property)->add($entity2, $entity2->rawGetField($indexField));
|
||||
}
|
||||
|
||||
public function addRelatedElement(Doctrine_Entity $entity1, $property,
|
||||
Doctrine_Entity $entity2)
|
||||
{
|
||||
$entity1->rawGetReference($property)->add($entity2);
|
||||
}
|
||||
|
||||
public function setRelatedElement(Doctrine_Entity $entity1, $property, $entity2)
|
||||
{
|
||||
$entity1->rawSetReference($property, $entity2);
|
||||
}
|
||||
|
||||
public function isIndexKeyInUse(Doctrine_Entity $entity, $assocField, $indexField)
|
||||
{
|
||||
return $entity->rawGetReference($assocField)->contains($indexField);
|
||||
}
|
||||
|
||||
public function isFieldSet(Doctrine_Entity $entity, $field)
|
||||
{
|
||||
return $entity->contains($field);
|
||||
}
|
||||
|
||||
public function getFieldValue(Doctrine_Entity $entity, $field)
|
||||
{
|
||||
return $entity->rawGetField($field);
|
||||
}
|
||||
|
||||
public function getReferenceValue(Doctrine_Entity $entity, $field)
|
||||
{
|
||||
return $entity->rawGetReference($field);
|
||||
}
|
||||
|
||||
public function addElementToIndexedCollection($coll, $entity, $keyField)
|
||||
{
|
||||
$coll->add($entity, $entity->rawGetField($keyField));
|
||||
}
|
||||
|
||||
public function addElementToCollection($coll, $entity)
|
||||
{
|
||||
$coll->add($entity);
|
||||
}
|
||||
|
||||
public function flush()
|
||||
@ -109,35 +150,8 @@ class Doctrine_Hydrator_RecordDriver
|
||||
$coll->takeSnapshot();
|
||||
}
|
||||
$this->_collections = array();
|
||||
$this->_mappers = array();
|
||||
$this->_initializedRelations = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the dataset for a discriminator column to determine the correct
|
||||
* class to instantiate. If no discriminator column is found, the given
|
||||
* classname will be returned.
|
||||
*
|
||||
* @return string The name of the class to instantiate.
|
||||
* @todo Can be optimized performance-wise.
|
||||
*/
|
||||
protected function _getClassnameToReturn(array $data, $className)
|
||||
{
|
||||
if ( ! isset($this->_mappers[$className])) {
|
||||
$this->_mappers[$className] = Doctrine_Manager::getInstance()->getMapper($className);
|
||||
}
|
||||
|
||||
$discCol = $this->_mappers[$className]->getClassMetadata()->getInheritanceOption('discriminatorColumn');
|
||||
if ( ! $discCol) {
|
||||
return $className;
|
||||
}
|
||||
|
||||
$discMap = $this->_mappers[$className]->getClassMetadata()->getInheritanceOption('discriminatorMap');
|
||||
|
||||
if (isset($data[$discCol], $discMap[$data[$discCol]])) {
|
||||
return $discMap[$data[$discCol]];
|
||||
} else {
|
||||
return $className;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,27 +77,32 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
|
||||
* )
|
||||
* @return mixed The created object/array graph.
|
||||
*/
|
||||
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null)
|
||||
public function hydrateResultSet($parserResult)
|
||||
{
|
||||
if ($hydrationMode === null) {
|
||||
if ($parserResult->getHydrationMode() === null) {
|
||||
$hydrationMode = $this->_hydrationMode;
|
||||
} else {
|
||||
$hydrationMode = $parserResult->getHydrationMode();
|
||||
}
|
||||
|
||||
$stmt = $parserResult->getDatabaseStatement();
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_NONE) {
|
||||
return $stmt->fetchAll(PDO::FETCH_NUM);
|
||||
}
|
||||
|
||||
$this->_tableAliases = $tableAliases;
|
||||
$this->_tableAliases = $parserResult->getTableToClassAliasMap();
|
||||
$this->_queryComponents = $parserResult->getQueryComponents();
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
|
||||
$driver = new Doctrine_Hydrator_ArrayDriver();
|
||||
} else {
|
||||
$driver = new Doctrine_Hydrator_RecordDriver();
|
||||
$driver = new Doctrine_Hydrator_RecordDriver($this->_em);
|
||||
}
|
||||
|
||||
$event = new Doctrine_Event(null, Doctrine_Event::HYDRATE, null);
|
||||
|
||||
//$s = microtime(true);
|
||||
$s = microtime(true);
|
||||
|
||||
// Used variables during hydration
|
||||
reset($this->_queryComponents);
|
||||
@ -120,7 +125,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
|
||||
$idTemplate = array();
|
||||
|
||||
// Holds the resulting hydrated data structure
|
||||
if ($this->_isResultMixed) {
|
||||
if ($parserResult->isMixedQuery()) {
|
||||
$result = array();
|
||||
} else {
|
||||
$result = $driver->getElementCollection($rootComponentName);
|
||||
@ -171,21 +176,25 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
|
||||
|
||||
// do we need to index by a custom field?
|
||||
if ($field = $this->_getCustomIndexField($rootAlias)) {
|
||||
if (isset($result[$field])) {
|
||||
// TODO: must be checked in the parser. fields used in INDEXBY
|
||||
// must be a) the primary key or b) unique & notnull
|
||||
/*if (isset($result[$field])) {
|
||||
throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping();
|
||||
} else if ( ! isset($element[$field])) {
|
||||
throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field);
|
||||
}
|
||||
if ($this->_isResultMixed) {
|
||||
$result[] = array($element[$field] => $element);
|
||||
}*/
|
||||
if ($parserResult->isMixedQuery()) {
|
||||
$result[] = array(
|
||||
$driver->getFieldValue($element, $field) => $element
|
||||
);
|
||||
} else {
|
||||
$result[$element[$field]] = $element;
|
||||
$driver->addElementToIndexedCollection($result, $element, $field);
|
||||
}
|
||||
} else {
|
||||
if ($this->_isResultMixed) {
|
||||
if ($parserResult->isMixedQuery()) {
|
||||
$result[] = array($element);
|
||||
} else {
|
||||
$result[] = $element;
|
||||
$driver->addElementToCollection($result, $element);
|
||||
}
|
||||
}
|
||||
$identifierMap[$rootAlias][$id[$rootAlias]] = $driver->getLastKey($result);
|
||||
@ -223,7 +232,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
|
||||
$path = $parent . '.' . $dqlAlias;
|
||||
|
||||
// pick the right element that will get the associated element attached
|
||||
if ($this->_isResultMixed && $parent == $rootAlias) {
|
||||
if ($parserResult->isMixedQuery() && $parent == $rootAlias) {
|
||||
$key = key(reset($resultPointers));
|
||||
// TODO: Exception if $key === null ?
|
||||
$baseElement =& $resultPointers[$parent][$key];
|
||||
@ -248,41 +257,44 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
|
||||
//--
|
||||
|
||||
if ($field = $this->_getCustomIndexField($dqlAlias)) {
|
||||
// TODO: we should check this earlier. Fields used in INDEXBY
|
||||
// must be unique. Then this can be removed here.
|
||||
if (isset($baseElement[$relationAlias][$field])) {
|
||||
// TODO: must be checked in the parser. fields used in INDEXBY
|
||||
// must be a) the primary key or b) unique & notnull
|
||||
/*if ($driver->isIndexKeyInUse($baseElement, $relationAlias, $field)) {
|
||||
throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping();
|
||||
} else if ( ! isset($element[$field])) {
|
||||
} else if ( ! $driver->isFieldSet($element, $field)) {
|
||||
throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field);
|
||||
}
|
||||
$baseElement[$relationAlias][$element[$field]] = $element;
|
||||
}*/
|
||||
$driver->addRelatedIndexedElement($baseElement, $relationAlias, $element, $field);
|
||||
} else {
|
||||
$baseElement[$relationAlias][] = $element;
|
||||
$driver->addRelatedElement($baseElement, $relationAlias, $element);
|
||||
}
|
||||
|
||||
$identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = $driver->getLastKey($baseElement[$relationAlias]);
|
||||
$identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = $driver->getLastKey(
|
||||
$driver->getReferenceValue($baseElement, $relationAlias));
|
||||
} else {
|
||||
$index = $identifierMap[$path][$id[$parent]][$id[$dqlAlias]];
|
||||
}
|
||||
} else if ( ! isset($baseElement[$relationAlias])) {
|
||||
$baseElement[$relationAlias] = $driver->getNullPointer();
|
||||
$driver->setRelatedElement($baseElement, $relationAlias,
|
||||
$driver->getNullPointer());
|
||||
}
|
||||
} else {
|
||||
// x-1 relation
|
||||
$oneToOne = true;
|
||||
if ( ! isset($nonemptyComponents[$dqlAlias])) {
|
||||
$baseElement[$relationAlias] = $driver->getNullPointer();
|
||||
} else if ( ! isset($baseElement[$relationAlias])) {
|
||||
$baseElement[$relationAlias] = $driver->getElement($data, $componentName);
|
||||
$driver->setRelatedElement($baseElement, $relationAlias,
|
||||
$driver->getNullPointer());
|
||||
} else if ( ! $driver->isFieldSet($baseElement, $relationAlias)) {
|
||||
$driver->setRelatedElement($baseElement, $relationAlias,
|
||||
$driver->getElement($data, $componentName));
|
||||
}
|
||||
}
|
||||
if ($baseElement[$relationAlias] !== null) {
|
||||
$coll =& $baseElement[$relationAlias];
|
||||
if (($coll =& $driver->getReferenceValue($baseElement, $relationAlias)) !== null) {
|
||||
$this->_setLastElement($resultPointers, $coll, $index, $dqlAlias, $oneToOne);
|
||||
}
|
||||
}
|
||||
|
||||
// append scalar values
|
||||
// append scalar values to mixed result sets
|
||||
if (isset($scalars)) {
|
||||
$rowNumber = count($result) - 1;
|
||||
foreach ($scalars as $name => $value) {
|
||||
@ -299,8 +311,8 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
|
||||
$data['table']->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, true);
|
||||
}
|
||||
|
||||
//$e = microtime(true);
|
||||
//echo 'Hydration took: ' . ($e - $s) . ' for '.count($result).' records<br />';
|
||||
$e = microtime(true);
|
||||
echo 'Hydration took: ' . ($e - $s) . ' for '.count($result).' records' . PHP_EOL;
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -339,7 +351,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
|
||||
end($coll);
|
||||
$resultPointers[$dqlAlias] =& $coll[key($coll)];
|
||||
}
|
||||
} else if ($coll instanceof Doctrine_Record) {
|
||||
} else if ($coll instanceof Doctrine_Entity) {
|
||||
$resultPointers[$dqlAlias] = $coll;
|
||||
} else if (count($coll) > 0) {
|
||||
$resultPointers[$dqlAlias] = $coll->getLast();
|
||||
|
@ -190,7 +190,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
|
||||
/**
|
||||
* importSchema
|
||||
*
|
||||
* method for importing existing schema to Doctrine_Record classes
|
||||
* method for importing existing schema to Doctrine_Entity classes
|
||||
*
|
||||
* @param string $directory
|
||||
* @param array $databases
|
||||
|
@ -23,7 +23,7 @@
|
||||
* class Doctrine_Import_Schema
|
||||
*
|
||||
* Different methods to import a XML schema. The logic behind using two different
|
||||
* methods is simple. Some people will like the idea of producing Doctrine_Record
|
||||
* methods is simple. Some people will like the idea of producing Doctrine_Entity
|
||||
* objects directly, which is totally fine. But in fast and growing application,
|
||||
* table definitions tend to be a little bit more volatile. importArr() can be used
|
||||
* to output a table definition in a PHP file. This file can then be stored
|
||||
@ -44,7 +44,7 @@ class Doctrine_Import_Schema
|
||||
'packagesPath' => '',
|
||||
'generateBaseClasses' => true,
|
||||
'baseClassesDirectory' => 'generated',
|
||||
'baseClassName' => 'Doctrine_Record',
|
||||
'baseClassName' => 'Doctrine_Entity',
|
||||
'suffix' => '.php');
|
||||
|
||||
/**
|
||||
@ -136,10 +136,10 @@ class Doctrine_Import_Schema
|
||||
/**
|
||||
* importSchema
|
||||
*
|
||||
* A method to import a Schema and translate it into a Doctrine_Record object
|
||||
* A method to import a Schema and translate it into a Doctrine_Entity object
|
||||
*
|
||||
* @param string $schema The file containing the XML schema
|
||||
* @param string $directory The directory where the Doctrine_Record class will be written
|
||||
* @param string $directory The directory where the Doctrine_Entity class will be written
|
||||
* @param array $models Optional array of models to import
|
||||
*
|
||||
* @return void
|
||||
|
@ -36,25 +36,25 @@ class Doctrine_Lib
|
||||
* getRecordStateAsString
|
||||
*
|
||||
* @param integer $state the state of record
|
||||
* @see Doctrine_Record::STATE_* constants
|
||||
* @see Doctrine_Entity::STATE_* constants
|
||||
* @return string string representation of given state
|
||||
*/
|
||||
public static function getRecordStateAsString($state)
|
||||
{
|
||||
switch ($state) {
|
||||
case Doctrine_Record::STATE_PROXY:
|
||||
case Doctrine_Entity::STATE_PROXY:
|
||||
return "proxy";
|
||||
break;
|
||||
case Doctrine_Record::STATE_CLEAN:
|
||||
case Doctrine_Entity::STATE_CLEAN:
|
||||
return "persistent clean";
|
||||
break;
|
||||
case Doctrine_Record::STATE_DIRTY:
|
||||
case Doctrine_Entity::STATE_DIRTY:
|
||||
return "persistent dirty";
|
||||
break;
|
||||
case Doctrine_Record::STATE_TDIRTY:
|
||||
case Doctrine_Entity::STATE_TDIRTY:
|
||||
return "transient dirty";
|
||||
break;
|
||||
case Doctrine_Record::STATE_TCLEAN:
|
||||
case Doctrine_Entity::STATE_TCLEAN:
|
||||
return "transient clean";
|
||||
break;
|
||||
}
|
||||
@ -63,12 +63,12 @@ class Doctrine_Lib
|
||||
/**
|
||||
* getRecordAsString
|
||||
*
|
||||
* returns a string representation of Doctrine_Record object
|
||||
* returns a string representation of Doctrine_Entity object
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return string
|
||||
*/
|
||||
public static function getRecordAsString(Doctrine_Record $record)
|
||||
public static function getRecordAsString(Doctrine_Entity $record)
|
||||
{
|
||||
$r[] = '<pre>';
|
||||
$r[] = 'Component : ' . $record->getTable()->getComponentName();
|
||||
|
@ -90,15 +90,15 @@ class Doctrine_Locking_Manager_Pessimistic
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a lock on a {@link Doctrine_Record}
|
||||
* Obtains a lock on a {@link Doctrine_Entity}
|
||||
*
|
||||
* @param Doctrine_Record $record The record that has to be locked
|
||||
* @param Doctrine_Entity $record The record that has to be locked
|
||||
* @param mixed $userIdent A unique identifier of the locking user
|
||||
* @return boolean TRUE if the locking was successful, FALSE if another user
|
||||
* holds a lock on this record
|
||||
* @throws Doctrine_Locking_Exception If the locking failed due to database errors
|
||||
*/
|
||||
public function getLock(Doctrine_Record $record, $userIdent)
|
||||
public function getLock(Doctrine_Entity $record, $userIdent)
|
||||
{
|
||||
$objectType = $record->getTable()->getComponentName();
|
||||
$key = $record->obtainIdentifier();
|
||||
@ -160,14 +160,14 @@ class Doctrine_Locking_Manager_Pessimistic
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases a lock on a {@link Doctrine_Record}
|
||||
* Releases a lock on a {@link Doctrine_Entity}
|
||||
*
|
||||
* @param Doctrine_Record $record The record for which the lock has to be released
|
||||
* @param Doctrine_Entity $record The record for which the lock has to be released
|
||||
* @param mixed $userIdent The unique identifier of the locking user
|
||||
* @return boolean TRUE if a lock was released, FALSE if no lock was released
|
||||
* @throws Doctrine_Locking_Exception If the release procedure failed due to database errors
|
||||
*/
|
||||
public function releaseLock(Doctrine_Record $record, $userIdent)
|
||||
public function releaseLock(Doctrine_Entity $record, $userIdent)
|
||||
{
|
||||
$objectType = $record->getTable()->getComponentName();
|
||||
$key = $record->obtainIdentifier();
|
||||
@ -235,7 +235,7 @@ class Doctrine_Locking_Manager_Pessimistic
|
||||
* Gets the identifier that identifies the owner of the lock on the given
|
||||
* record.
|
||||
*
|
||||
* @param Doctrine_Record $lockedRecord The record.
|
||||
* @param Doctrine_Entity $lockedRecord The record.
|
||||
* @return mixed The unique user identifier that identifies the owner of the lock.
|
||||
*/
|
||||
public function getLockOwner($lockedRecord)
|
||||
|
@ -68,6 +68,8 @@ class Doctrine_Mapper
|
||||
* A list of registered entity listeners.
|
||||
*/
|
||||
private $_entityListeners = array();
|
||||
|
||||
private $_dataTemplate = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -118,7 +120,7 @@ class Doctrine_Mapper
|
||||
*
|
||||
* @param $array an array where keys are field names and
|
||||
* values representing field values
|
||||
* @return Doctrine_Record the created record object
|
||||
* @return Doctrine_Entity the created record object
|
||||
*/
|
||||
public function create(array $array = array())
|
||||
{
|
||||
@ -146,7 +148,7 @@ class Doctrine_Mapper
|
||||
return false;
|
||||
}
|
||||
|
||||
public function notifyEntityListeners(Doctrine_Record $entity, $callback, $eventType)
|
||||
public function notifyEntityListeners(Doctrine_Entity $entity, $callback, $eventType)
|
||||
{
|
||||
if ($this->_entityListeners) {
|
||||
$event = new Doctrine_Event($entity, $eventType);
|
||||
@ -156,7 +158,7 @@ class Doctrine_Mapper
|
||||
}
|
||||
}
|
||||
|
||||
public function detach(Doctrine_Record $entity)
|
||||
public function detach(Doctrine_Entity $entity)
|
||||
{
|
||||
return $this->_conn->unitOfWork->detach($entity);
|
||||
}
|
||||
@ -192,11 +194,11 @@ class Doctrine_Mapper
|
||||
* addRecord
|
||||
* adds a record to identity map
|
||||
*
|
||||
* @param Doctrine_Record $record record to be added
|
||||
* @param Doctrine_Entity $record record to be added
|
||||
* @return boolean
|
||||
* @todo Better name? registerRecord? Move elsewhere to the new location of the identity maps.
|
||||
*/
|
||||
public function addRecord(Doctrine_Record $record)
|
||||
public function addRecord(Doctrine_Entity $record)
|
||||
{
|
||||
if ($this->_conn->unitOfWork->contains($record)) {
|
||||
return false;
|
||||
@ -212,7 +214,7 @@ class Doctrine_Mapper
|
||||
* @return boolean TRUE if the entity was previously not managed and is now managed,
|
||||
* FALSE otherwise (the entity is already managed).
|
||||
*/
|
||||
public function manage(Doctrine_Record $record)
|
||||
public function manage(Doctrine_Entity $record)
|
||||
{
|
||||
return $this->_conn->unitOfWork->manage($record);
|
||||
}
|
||||
@ -222,11 +224,11 @@ class Doctrine_Mapper
|
||||
* removes a record from the identity map, returning true if the record
|
||||
* was found and removed and false if the record wasn't found.
|
||||
*
|
||||
* @param Doctrine_Record $record record to be removed
|
||||
* @param Doctrine_Entity $record record to be removed
|
||||
* @return boolean
|
||||
* @todo Move elsewhere to the new location of the identity maps.
|
||||
*/
|
||||
public function removeRecord(Doctrine_Record $record)
|
||||
public function removeRecord(Doctrine_Entity $record)
|
||||
{
|
||||
if ($this->_conn->unitOfWork->contains($record)) {
|
||||
$this->_conn->unitOfWork->unregisterIdentity($record);
|
||||
@ -241,7 +243,7 @@ class Doctrine_Mapper
|
||||
* First checks if record exists in identityMap, if not
|
||||
* returns a new record.
|
||||
*
|
||||
* @return Doctrine_Record
|
||||
* @return Doctrine_Entity
|
||||
*/
|
||||
public function getRecord(array $data)
|
||||
{
|
||||
@ -401,7 +403,7 @@ class Doctrine_Mapper
|
||||
* Hydrates the given data into the entity.
|
||||
*
|
||||
*/
|
||||
/*public function hydrate(Doctrine_Record $entity, array $data)
|
||||
/*public function hydrate(Doctrine_Entity $entity, array $data)
|
||||
{
|
||||
$this->_values = array_merge($this->_values, $this->cleanData($data));
|
||||
$this->_data = array_merge($this->_data, $data);
|
||||
@ -456,12 +458,12 @@ class Doctrine_Mapper
|
||||
/**
|
||||
* Saves an entity and all it's related entities.
|
||||
*
|
||||
* @param Doctrine_Record $record The entity to save.
|
||||
* @param Doctrine_Entity $record The entity to save.
|
||||
* @param Doctrine_Connection $conn The connection to use. Will default to the mapper's
|
||||
* connection.
|
||||
* @throws Doctrine_Mapper_Exception If the mapper is unable to save the given entity.
|
||||
*/
|
||||
public function save(Doctrine_Record $record, Doctrine_Connection $conn = null)
|
||||
public function save(Doctrine_Entity $record, Doctrine_Connection $conn = null)
|
||||
{
|
||||
if ( ! ($record instanceof $this->_domainClassName)) {
|
||||
throw new Doctrine_Mapper_Exception("Mapper of type " . $this->_domainClassName . "
|
||||
@ -473,11 +475,11 @@ class Doctrine_Mapper
|
||||
}
|
||||
|
||||
$state = $record->state();
|
||||
if ($state === Doctrine_Record::STATE_LOCKED) {
|
||||
if ($state === Doctrine_Entity::STATE_LOCKED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$record->state(Doctrine_Record::STATE_LOCKED);
|
||||
$record->state(Doctrine_Entity::STATE_LOCKED);
|
||||
|
||||
try {
|
||||
$conn->beginInternalTransaction();
|
||||
@ -492,7 +494,7 @@ class Doctrine_Mapper
|
||||
}
|
||||
|
||||
$state = $record->state();
|
||||
$record->state(Doctrine_Record::STATE_LOCKED);
|
||||
$record->state(Doctrine_Entity::STATE_LOCKED);
|
||||
|
||||
foreach ($saveLater as $fk) {
|
||||
$alias = $fk->getAlias();
|
||||
@ -521,23 +523,23 @@ class Doctrine_Mapper
|
||||
/**
|
||||
* Inserts or updates an entity, depending on it's state.
|
||||
*
|
||||
* @param Doctrine_Record $record The entity to insert/update.
|
||||
* @param Doctrine_Entity $record The entity to insert/update.
|
||||
*/
|
||||
protected function _insertOrUpdate(Doctrine_Record $record)
|
||||
protected function _insertOrUpdate(Doctrine_Entity $record)
|
||||
{
|
||||
$record->preSave();
|
||||
$this->notifyEntityListeners($record, 'preSave', Doctrine_Event::RECORD_SAVE);
|
||||
|
||||
switch ($record->state()) {
|
||||
case Doctrine_Record::STATE_TDIRTY:
|
||||
case Doctrine_Entity::STATE_TDIRTY:
|
||||
$this->_insert($record);
|
||||
break;
|
||||
case Doctrine_Record::STATE_DIRTY:
|
||||
case Doctrine_Record::STATE_PROXY:
|
||||
case Doctrine_Entity::STATE_DIRTY:
|
||||
case Doctrine_Entity::STATE_PROXY:
|
||||
$this->_update($record);
|
||||
break;
|
||||
case Doctrine_Record::STATE_CLEAN:
|
||||
case Doctrine_Record::STATE_TCLEAN:
|
||||
case Doctrine_Entity::STATE_CLEAN:
|
||||
case Doctrine_Entity::STATE_TCLEAN:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
@ -549,10 +551,10 @@ class Doctrine_Mapper
|
||||
/**
|
||||
* saves the given record
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return void
|
||||
*/
|
||||
public function saveSingleRecord(Doctrine_Record $record)
|
||||
public function saveSingleRecord(Doctrine_Entity $record)
|
||||
{
|
||||
$this->_insertOrUpdate($record);
|
||||
}
|
||||
@ -562,9 +564,9 @@ class Doctrine_Mapper
|
||||
* saves all related records to $record
|
||||
*
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
*/
|
||||
protected function _saveRelated(Doctrine_Record $record)
|
||||
protected function _saveRelated(Doctrine_Entity $record)
|
||||
{
|
||||
$saveLater = array();
|
||||
foreach ($record->getReferences() as $k => $v) {
|
||||
@ -580,7 +582,7 @@ class Doctrine_Mapper
|
||||
$obj = $record->get($rel->getAlias());
|
||||
|
||||
// Protection against infinite function recursion before attempting to save
|
||||
if ($obj instanceof Doctrine_Record && $obj->isModified()) {
|
||||
if ($obj instanceof Doctrine_Entity && $obj->isModified()) {
|
||||
$obj->save($this->_conn);
|
||||
|
||||
/** Can this be removed?
|
||||
@ -609,10 +611,10 @@ class Doctrine_Mapper
|
||||
* save new associations to 4 and 5
|
||||
*
|
||||
* @throws Doctrine_Connection_Exception if something went wrong at database level
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return void
|
||||
*/
|
||||
public function saveAssociations(Doctrine_Record $record)
|
||||
public function saveAssociations(Doctrine_Entity $record)
|
||||
{
|
||||
foreach ($record->getReferences() as $relationName => $relatedObject) {
|
||||
if ($relatedObject === Doctrine_Null::$INSTANCE) {
|
||||
@ -650,11 +652,11 @@ class Doctrine_Mapper
|
||||
/**
|
||||
* Updates an entity.
|
||||
*
|
||||
* @param Doctrine_Record $record record to be updated
|
||||
* @param Doctrine_Entity $record record to be updated
|
||||
* @return boolean whether or not the update was successful
|
||||
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
|
||||
*/
|
||||
protected function _update(Doctrine_Record $record)
|
||||
protected function _update(Doctrine_Entity $record)
|
||||
{
|
||||
$record->preUpdate();
|
||||
$this->notifyEntityListeners($record, 'preUpdate', Doctrine_Event::RECORD_UPDATE);
|
||||
@ -671,10 +673,10 @@ class Doctrine_Mapper
|
||||
/**
|
||||
* Inserts an entity.
|
||||
*
|
||||
* @param Doctrine_Record $record record to be inserted
|
||||
* @param Doctrine_Entity $record record to be inserted
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _insert(Doctrine_Record $record)
|
||||
protected function _insert(Doctrine_Entity $record)
|
||||
{
|
||||
$record->preInsert();
|
||||
$this->notifyEntityListeners($record, 'preInsert', Doctrine_Event::RECORD_INSERT);
|
||||
@ -696,7 +698,7 @@ class Doctrine_Mapper
|
||||
* @return boolean true on success, false on failure
|
||||
* @throws Doctrine_Mapper_Exception
|
||||
*/
|
||||
public function delete(Doctrine_Record $record, Doctrine_Connection $conn = null)
|
||||
public function delete(Doctrine_Entity $record, Doctrine_Connection $conn = null)
|
||||
{
|
||||
if ( ! $record->exists()) {
|
||||
return false;
|
||||
@ -717,7 +719,7 @@ class Doctrine_Mapper
|
||||
$table = $this->_classMetadata;
|
||||
|
||||
$state = $record->state();
|
||||
$record->state(Doctrine_Record::STATE_LOCKED);
|
||||
$record->state(Doctrine_Entity::STATE_LOCKED);
|
||||
|
||||
$this->_mappingStrategy->doDelete($record);
|
||||
|
||||
|
@ -36,7 +36,7 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
|
||||
/**
|
||||
* Deletes an entity.
|
||||
*/
|
||||
public function doDelete(Doctrine_Record $record)
|
||||
public function doDelete(Doctrine_Entity $record)
|
||||
{
|
||||
$conn = $this->_mapper->getConnection();
|
||||
$metadata = $this->_mapper->getClassMetadata();
|
||||
@ -44,11 +44,11 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
|
||||
$conn->beginInternalTransaction();
|
||||
$this->_deleteComposites($record);
|
||||
|
||||
$record->state(Doctrine_Record::STATE_TDIRTY);
|
||||
$record->state(Doctrine_Entity::STATE_TDIRTY);
|
||||
|
||||
$identifier = $this->_convertFieldToColumnNames($record->identifier(), $metadata);
|
||||
$this->_deleteRow($metadata->getTableName(), $identifier);
|
||||
$record->state(Doctrine_Record::STATE_TCLEAN);
|
||||
$record->state(Doctrine_Entity::STATE_TCLEAN);
|
||||
|
||||
$this->_mapper->removeRecord($record);
|
||||
$conn->commit();
|
||||
@ -61,9 +61,9 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
|
||||
/**
|
||||
* Inserts a single entity into the database, without any related entities.
|
||||
*
|
||||
* @param Doctrine_Record $record The entity to insert.
|
||||
* @param Doctrine_Entity $record The entity to insert.
|
||||
*/
|
||||
public function doInsert(Doctrine_Record $record)
|
||||
public function doInsert(Doctrine_Entity $record)
|
||||
{
|
||||
$conn = $this->_mapper->getConnection();
|
||||
|
||||
@ -108,7 +108,7 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
|
||||
/**
|
||||
* Updates an entity.
|
||||
*/
|
||||
public function doUpdate(Doctrine_Record $record)
|
||||
public function doUpdate(Doctrine_Entity $record)
|
||||
{
|
||||
$conn = $this->_mapper->getConnection();
|
||||
$classMetadata = $this->_mapper->getClassMetadata();
|
||||
|
@ -38,10 +38,10 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
|
||||
/**
|
||||
* Inserts an entity that is part of a Class Table Inheritance hierarchy.
|
||||
*
|
||||
* @param Doctrine_Record $record record to be inserted
|
||||
* @param Doctrine_Entity $record record to be inserted
|
||||
* @return boolean
|
||||
*/
|
||||
public function doInsert(Doctrine_Record $record)
|
||||
public function doInsert(Doctrine_Entity $record)
|
||||
{
|
||||
$class = $this->_mapper->getClassMetadata();
|
||||
$conn = $this->_mapper->getConnection();
|
||||
@ -92,11 +92,11 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
|
||||
/**
|
||||
* Updates an entity that is part of a Class Table Inheritance hierarchy.
|
||||
*
|
||||
* @param Doctrine_Record $record record to be updated
|
||||
* @param Doctrine_Entity $record record to be updated
|
||||
* @return boolean whether or not the update was successful
|
||||
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
|
||||
*/
|
||||
public function doUpdate(Doctrine_Record $record)
|
||||
public function doUpdate(Doctrine_Entity $record)
|
||||
{
|
||||
$conn = $this->_mapper->getConnection();
|
||||
$classMetadata = $this->_mapper->getClassMetadata();
|
||||
@ -107,7 +107,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
|
||||
array_unshift($classes, $component);
|
||||
|
||||
foreach ($record as $field => $value) {
|
||||
if ($value instanceof Doctrine_Record) {
|
||||
if ($value instanceof Doctrine_Entity) {
|
||||
if ( ! $value->exists()) {
|
||||
$value->save();
|
||||
}
|
||||
@ -130,7 +130,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
|
||||
* Deletes an entity that is part of a Class Table Inheritance hierarchy.
|
||||
*
|
||||
*/
|
||||
public function doDelete(Doctrine_Record $record)
|
||||
public function doDelete(Doctrine_Entity $record)
|
||||
{
|
||||
$conn = $this->_mapper->getConnection();
|
||||
try {
|
||||
@ -138,7 +138,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
|
||||
$conn->beginInternalTransaction();
|
||||
$this->_deleteComposites($record);
|
||||
|
||||
$record->state(Doctrine_Record::STATE_TDIRTY);
|
||||
$record->state(Doctrine_Entity::STATE_TDIRTY);
|
||||
|
||||
$identifier = $this->_convertFieldToColumnNames($record->identifier(), $class);
|
||||
|
||||
@ -149,7 +149,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
|
||||
$this->_deleteRow($parentClass->getTableName(), $identifier);
|
||||
}
|
||||
|
||||
$record->state(Doctrine_Record::STATE_TCLEAN);
|
||||
$record->state(Doctrine_Entity::STATE_TCLEAN);
|
||||
|
||||
$this->_mapper->removeRecord($record);
|
||||
$conn->commit();
|
||||
@ -286,7 +286,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _groupFieldsByDefiningClass(Doctrine_Record $record)
|
||||
protected function _groupFieldsByDefiningClass(Doctrine_Entity $record)
|
||||
{
|
||||
$conn = $this->_mapper->getConnection();
|
||||
$classMetadata = $this->_mapper->getClassMetadata();
|
||||
|
@ -67,14 +67,14 @@ abstract class Doctrine_Mapper_Strategy
|
||||
* @throws PDOException if something went wrong at database level
|
||||
* @return void
|
||||
*/
|
||||
protected function _deleteComposites(Doctrine_Record $record)
|
||||
protected function _deleteComposites(Doctrine_Entity $record)
|
||||
{
|
||||
$classMetadata = $this->_mapper->getClassMetadata();
|
||||
foreach ($classMetadata->getRelations() as $fk) {
|
||||
if ($fk->isComposite()) {
|
||||
$obj = $record->get($fk->getAlias());
|
||||
if ($obj instanceof Doctrine_Record &&
|
||||
$obj->state() != Doctrine_Record::STATE_LOCKED) {
|
||||
if ($obj instanceof Doctrine_Entity &&
|
||||
$obj->state() != Doctrine_Entity::STATE_LOCKED) {
|
||||
$obj->delete($this->_mapper->getConnection());
|
||||
}
|
||||
}
|
||||
@ -116,9 +116,9 @@ abstract class Doctrine_Mapper_Strategy
|
||||
return $this->_mapper->getClassMetadata();
|
||||
}
|
||||
|
||||
abstract public function doDelete(Doctrine_Record $record);
|
||||
abstract public function doInsert(Doctrine_Record $record);
|
||||
abstract public function doUpdate(Doctrine_Record $record);
|
||||
abstract public function doDelete(Doctrine_Entity $record);
|
||||
abstract public function doInsert(Doctrine_Entity $record);
|
||||
abstract public function doUpdate(Doctrine_Entity $record);
|
||||
|
||||
/**
|
||||
* Inserts a row into a table.
|
||||
|
@ -33,7 +33,7 @@
|
||||
class Doctrine_Node implements IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @param object $record reference to associated Doctrine_Record instance
|
||||
* @param object $record reference to associated Doctrine_Entity instance
|
||||
*/
|
||||
protected $record;
|
||||
|
||||
@ -62,10 +62,10 @@ class Doctrine_Node implements IteratorAggregate
|
||||
/**
|
||||
* contructor, creates node with reference to record and any options
|
||||
*
|
||||
* @param object $record instance of Doctrine_Record
|
||||
* @param object $record instance of Doctrine_Entity
|
||||
* @param array $options options
|
||||
*/
|
||||
public function __construct(Doctrine_Record $record, $options)
|
||||
public function __construct(Doctrine_Entity $record, $options)
|
||||
{
|
||||
$this->record = $record;
|
||||
$this->options = $options;
|
||||
@ -90,12 +90,12 @@ class Doctrine_Node implements IteratorAggregate
|
||||
/**
|
||||
* factory method to return node instance based upon chosen implementation
|
||||
*
|
||||
* @param object $record instance of Doctrine_Record
|
||||
* @param object $record instance of Doctrine_Entity
|
||||
* @param string $impName implementation (NestedSet, AdjacencyList, MaterializedPath)
|
||||
* @param array $options options
|
||||
* @return object $options instance of Doctrine_Node
|
||||
*/
|
||||
public static function factory(Doctrine_Record $record, $implName, $options = array())
|
||||
public static function factory(Doctrine_Entity $record, $implName, $options = array())
|
||||
{
|
||||
$class = 'Doctrine_Node_' . $implName;
|
||||
|
||||
@ -109,9 +109,9 @@ class Doctrine_Node implements IteratorAggregate
|
||||
/**
|
||||
* setter for record attribute
|
||||
*
|
||||
* @param object $record instance of Doctrine_Record
|
||||
* @param object $record instance of Doctrine_Entity
|
||||
*/
|
||||
public function setRecord(Doctrine_Record $record)
|
||||
public function setRecord(Doctrine_Entity $record)
|
||||
{
|
||||
$this->record = $record;
|
||||
}
|
||||
@ -119,7 +119,7 @@ class Doctrine_Node implements IteratorAggregate
|
||||
/**
|
||||
* getter for record attribute
|
||||
*
|
||||
* @return object instance of Doctrine_Record
|
||||
* @return object instance of Doctrine_Entity
|
||||
*/
|
||||
public function getRecord()
|
||||
{
|
||||
|
@ -63,42 +63,42 @@ interface Doctrine_Node_Interface {
|
||||
/**
|
||||
* gets record of prev sibling or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getPrevSibling();
|
||||
|
||||
/**
|
||||
* gets record of next sibling or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getNextSibling();
|
||||
|
||||
/**
|
||||
* gets siblings for node
|
||||
*
|
||||
* @return array array of sibling Doctrine_Record objects
|
||||
* @return array array of sibling Doctrine_Entity objects
|
||||
*/
|
||||
public function getSiblings($includeNode = false);
|
||||
|
||||
/**
|
||||
* gets record of first child or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getFirstChild();
|
||||
|
||||
/**
|
||||
* gets record of last child or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getLastChild();
|
||||
|
||||
/**
|
||||
* gets children for node (direct descendants only)
|
||||
*
|
||||
* @return array array of sibling Doctrine_Record objects
|
||||
* @return array array of sibling Doctrine_Entity objects
|
||||
*/
|
||||
public function getChildren();
|
||||
|
||||
@ -112,7 +112,7 @@ interface Doctrine_Node_Interface {
|
||||
/**
|
||||
* gets record of parent or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getParent();
|
||||
|
||||
@ -158,65 +158,65 @@ interface Doctrine_Node_Interface {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function insertAsParentOf(Doctrine_Record $dest);
|
||||
public function insertAsParentOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* inserts node as previous sibling of dest record
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function insertAsPrevSiblingOf(Doctrine_Record $dest);
|
||||
public function insertAsPrevSiblingOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* inserts node as next sibling of dest record
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function insertAsNextSiblingOf(Doctrine_Record $dest);
|
||||
public function insertAsNextSiblingOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* inserts node as first child of dest record
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function insertAsFirstChildOf(Doctrine_Record $dest);
|
||||
public function insertAsFirstChildOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* inserts node as first child of dest record
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function insertAsLastChildOf(Doctrine_Record $dest);
|
||||
public function insertAsLastChildOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* moves node as prev sibling of dest record
|
||||
*
|
||||
*/
|
||||
public function moveAsPrevSiblingOf(Doctrine_Record $dest);
|
||||
public function moveAsPrevSiblingOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* moves node as next sibling of dest record
|
||||
*
|
||||
*/
|
||||
public function moveAsNextSiblingOf(Doctrine_Record $dest);
|
||||
public function moveAsNextSiblingOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* moves node as first child of dest record
|
||||
*
|
||||
*/
|
||||
public function moveAsFirstChildOf(Doctrine_Record $dest);
|
||||
public function moveAsFirstChildOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* moves node as last child of dest record
|
||||
*
|
||||
*/
|
||||
public function moveAsLastChildOf(Doctrine_Record $dest);
|
||||
public function moveAsLastChildOf(Doctrine_Entity $dest);
|
||||
|
||||
/**
|
||||
* adds node as last child of record
|
||||
*
|
||||
*/
|
||||
public function addChild(Doctrine_Record $record);
|
||||
public function addChild(Doctrine_Entity $record);
|
||||
|
||||
/**
|
||||
* determines if node is leaf
|
||||
@ -237,21 +237,21 @@ interface Doctrine_Node_Interface {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEqualTo(Doctrine_Record $subj);
|
||||
public function isEqualTo(Doctrine_Entity $subj);
|
||||
|
||||
/**
|
||||
* determines if node is child of subject node
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDescendantOf(Doctrine_Record $subj);
|
||||
public function isDescendantOf(Doctrine_Entity $subj);
|
||||
|
||||
/**
|
||||
* determines if node is child of or sibling to subject node
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDescendantOfOrEqualTo(Doctrine_Record $subj);
|
||||
public function isDescendantOfOrEqualTo(Doctrine_Entity $subj);
|
||||
|
||||
/**
|
||||
* determines if node is valid
|
||||
|
@ -76,7 +76,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
/**
|
||||
* gets record of prev sibling or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getPrevSibling()
|
||||
{
|
||||
@ -102,7 +102,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
/**
|
||||
* gets record of next sibling or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getNextSibling()
|
||||
{
|
||||
@ -128,7 +128,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
/**
|
||||
* gets siblings for node
|
||||
*
|
||||
* @return array array of sibling Doctrine_Record objects
|
||||
* @return array array of sibling Doctrine_Entity objects
|
||||
*/
|
||||
public function getSiblings($includeNode = false)
|
||||
{
|
||||
@ -148,7 +148,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
/**
|
||||
* gets record of first child or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getFirstChild()
|
||||
{
|
||||
@ -174,7 +174,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
/**
|
||||
* gets record of last child or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getLastChild()
|
||||
{
|
||||
@ -243,7 +243,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
/**
|
||||
* gets record of parent or empty record
|
||||
*
|
||||
* @return object Doctrine_Record
|
||||
* @return object Doctrine_Entity
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
@ -340,7 +340,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* @return bool
|
||||
* @todo Wrap in transaction
|
||||
*/
|
||||
public function insertAsParentOf(Doctrine_Record $dest)
|
||||
public function insertAsParentOf(Doctrine_Entity $dest)
|
||||
{
|
||||
// cannot insert a node that has already has a place within the tree
|
||||
if ($this->isValidNode()) {
|
||||
@ -382,7 +382,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* @return bool
|
||||
* @todo Wrap in transaction
|
||||
*/
|
||||
public function insertAsPrevSiblingOf(Doctrine_Record $dest)
|
||||
public function insertAsPrevSiblingOf(Doctrine_Entity $dest)
|
||||
{
|
||||
// cannot insert a node that has already has a place within the tree
|
||||
if ($this->isValidNode())
|
||||
@ -408,7 +408,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* @return bool
|
||||
* @todo Wrap in transaction
|
||||
*/
|
||||
public function insertAsNextSiblingOf(Doctrine_Record $dest)
|
||||
public function insertAsNextSiblingOf(Doctrine_Entity $dest)
|
||||
{
|
||||
// cannot insert a node that has already has a place within the tree
|
||||
if ($this->isValidNode())
|
||||
@ -434,7 +434,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* @return bool
|
||||
* @todo Wrap in transaction
|
||||
*/
|
||||
public function insertAsFirstChildOf(Doctrine_Record $dest)
|
||||
public function insertAsFirstChildOf(Doctrine_Entity $dest)
|
||||
{
|
||||
// cannot insert a node that has already has a place within the tree
|
||||
if ($this->isValidNode())
|
||||
@ -460,7 +460,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* @return bool
|
||||
* @todo Wrap in transaction
|
||||
*/
|
||||
public function insertAsLastChildOf(Doctrine_Record $dest)
|
||||
public function insertAsLastChildOf(Doctrine_Entity $dest)
|
||||
{
|
||||
// cannot insert a node that has already has a place within the tree
|
||||
if ($this->isValidNode())
|
||||
@ -484,12 +484,12 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* Accomplishes moving of nodes between different trees.
|
||||
* Used by the move* methods if the root values of the two nodes are different.
|
||||
*
|
||||
* @param Doctrine_Record $dest
|
||||
* @param Doctrine_Entity $dest
|
||||
* @param unknown_type $newLeftValue
|
||||
* @param unknown_type $moveType
|
||||
* @todo Better exception handling/wrapping
|
||||
*/
|
||||
private function _moveBetweenTrees(Doctrine_Record $dest, $newLeftValue, $moveType)
|
||||
private function _moveBetweenTrees(Doctrine_Entity $dest, $newLeftValue, $moveType)
|
||||
{
|
||||
$conn = $this->record->getTable()->getConnection();
|
||||
|
||||
@ -571,7 +571,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* moves node as prev sibling of dest record
|
||||
*
|
||||
*/
|
||||
public function moveAsPrevSiblingOf(Doctrine_Record $dest)
|
||||
public function moveAsPrevSiblingOf(Doctrine_Entity $dest)
|
||||
{
|
||||
if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
|
||||
// Move between trees
|
||||
@ -588,7 +588,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* moves node as next sibling of dest record
|
||||
*
|
||||
*/
|
||||
public function moveAsNextSiblingOf(Doctrine_Record $dest)
|
||||
public function moveAsNextSiblingOf(Doctrine_Entity $dest)
|
||||
{
|
||||
if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
|
||||
// Move between trees
|
||||
@ -605,7 +605,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* moves node as first child of dest record
|
||||
*
|
||||
*/
|
||||
public function moveAsFirstChildOf(Doctrine_Record $dest)
|
||||
public function moveAsFirstChildOf(Doctrine_Entity $dest)
|
||||
{
|
||||
if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
|
||||
// Move between trees
|
||||
@ -622,7 +622,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* moves node as last child of dest record
|
||||
*
|
||||
*/
|
||||
public function moveAsLastChildOf(Doctrine_Record $dest)
|
||||
public function moveAsLastChildOf(Doctrine_Entity $dest)
|
||||
{
|
||||
if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
|
||||
// Move between trees
|
||||
@ -695,7 +695,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
* adds node as last child of record
|
||||
*
|
||||
*/
|
||||
public function addChild(Doctrine_Record $record)
|
||||
public function addChild(Doctrine_Entity $record)
|
||||
{
|
||||
$record->getNode()->insertAsLastChildOf($this->getRecord());
|
||||
}
|
||||
@ -725,7 +725,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEqualTo(Doctrine_Record $subj)
|
||||
public function isEqualTo(Doctrine_Entity $subj)
|
||||
{
|
||||
return (($this->getLeftValue() == $subj->getNode()->getLeftValue()) &&
|
||||
($this->getRightValue() == $subj->getNode()->getRightValue()) &&
|
||||
@ -738,7 +738,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDescendantOf(Doctrine_Record $subj)
|
||||
public function isDescendantOf(Doctrine_Entity $subj)
|
||||
{
|
||||
return (($this->getLeftValue() > $subj->getNode()->getLeftValue()) &&
|
||||
($this->getRightValue() < $subj->getNode()->getRightValue()) &&
|
||||
@ -750,7 +750,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDescendantOfOrEqualTo(Doctrine_Record $subj)
|
||||
public function isDescendantOfOrEqualTo(Doctrine_Entity $subj)
|
||||
{
|
||||
return (($this->getLeftValue() >= $subj->getNode()->getLeftValue()) &&
|
||||
($this->getRightValue() <= $subj->getNode()->getRightValue()) &&
|
||||
@ -766,7 +766,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
|
||||
{
|
||||
if ($record === null) {
|
||||
return ($this->getRightValue() > $this->getLeftValue());
|
||||
} else if ( $record instanceof Doctrine_Record ) {
|
||||
} else if ( $record instanceof Doctrine_Entity ) {
|
||||
return ($record->getNode()->getRightValue() > $record->getNode()->getLeftValue());
|
||||
} else {
|
||||
return false;
|
||||
|
@ -119,7 +119,7 @@ class Doctrine_Node_NestedSet_PreOrderIterator implements Iterator
|
||||
/**
|
||||
* returns the current record
|
||||
*
|
||||
* @return Doctrine_Record
|
||||
* @return Doctrine_Entity
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
|
@ -1797,7 +1797,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
|
||||
* unseralize
|
||||
* this method is automatically called everytime a Doctrine_Hydrate object is unserialized
|
||||
*
|
||||
* @param string $serialized Doctrine_Record as serialized string
|
||||
* @param string $serialized Doctrine_Entity as serialized string
|
||||
* @return void
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
|
@ -249,7 +249,7 @@ abstract class Doctrine_Query_Abstract
|
||||
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
|
||||
}
|
||||
if ($hydrator === null) {
|
||||
$hydrator = new Doctrine_Hydrator();
|
||||
$hydrator = new Doctrine_Hydrator($connection);
|
||||
}
|
||||
$this->_conn = $connection;
|
||||
$this->_hydrator = $hydrator;
|
||||
@ -988,9 +988,9 @@ abstract class Doctrine_Query_Abstract
|
||||
if ($cached === false) {
|
||||
// cache miss
|
||||
$stmt = $this->_execute($params);
|
||||
$this->_hydrator->setQueryComponents($this->_queryComponents);
|
||||
$result = $this->_hydrator->hydrateResultSet($stmt, $this->_tableAliasMap,
|
||||
Doctrine::HYDRATE_ARRAY);
|
||||
$result = $this->_hydrator->hydrateResultSet(
|
||||
$this->_createParserResult($stmt, $this->_queryComponents,
|
||||
$this->_tableAliasMap, Doctrine::HYDRATE_ARRAY));
|
||||
|
||||
$cached = $this->getCachedForm($result);
|
||||
$cacheDriver->save($hash, $cached, $this->_resultCacheTTL);
|
||||
@ -1005,11 +1005,32 @@ abstract class Doctrine_Query_Abstract
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
$this->_hydrator->setQueryComponents($this->_queryComponents);
|
||||
return $this->_hydrator->hydrateResultSet($stmt, $this->_tableAliasMap, $hydrationMode);
|
||||
return $this->_hydrator->hydrateResultSet(
|
||||
$this->_createParserResult($stmt, $this->_queryComponents,
|
||||
$this->_tableAliasMap, $hydrationMode));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a parser result object.
|
||||
*
|
||||
* @param unknown_type $stmt
|
||||
* @param unknown_type $queryComponents
|
||||
* @param unknown_type $tableToClassAliasMap
|
||||
* @param unknown_type $hydrationMode
|
||||
* @return unknown
|
||||
*/
|
||||
private function _createParserResult($stmt, $queryComponents, $tableToClassAliasMap,
|
||||
$hydrationMode)
|
||||
{
|
||||
$parserResult = new Doctrine_Query_ParserResultDummy();
|
||||
$parserResult->setDatabaseStatement($stmt);
|
||||
$parserResult->setHydrationMode($hydrationMode);
|
||||
$parserResult->setQueryComponents($queryComponents);
|
||||
$parserResult->setTableToClassAliasMap($tableToClassAliasMap);
|
||||
return $parserResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the query from the cached form.
|
||||
*
|
||||
|
75
lib/Doctrine/Query/ParserResultDummy.php
Normal file
75
lib/Doctrine/Query/ParserResultDummy.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This class is just an intermediate implementation for refactoring purposes
|
||||
* and will be replaced by the ParserResult class of the new DQL parser branch.
|
||||
*
|
||||
*/
|
||||
class Doctrine_Query_ParserResultDummy
|
||||
{
|
||||
private $_isMixedQuery;
|
||||
private $_dbStatement;
|
||||
private $_isIdentityQuery;
|
||||
private $_hydrationMode;
|
||||
private $_tableToClassAliasMap;
|
||||
private $_queryComponents;
|
||||
|
||||
|
||||
public function isMixedQuery()
|
||||
{
|
||||
return $this->_isMixedQuery;
|
||||
}
|
||||
|
||||
public function isIdentityQuery()
|
||||
{
|
||||
return $this->_isIdentityQuery;
|
||||
}
|
||||
|
||||
public function setMixedQuery($bool)
|
||||
{
|
||||
$this->_isMixedQuery = (bool) $bool;
|
||||
}
|
||||
|
||||
public function getDatabaseStatement()
|
||||
{
|
||||
return $this->_dbStatement;
|
||||
}
|
||||
|
||||
public function setDatabaseStatement($stmt)
|
||||
{
|
||||
$this->_dbStatement = $stmt;
|
||||
}
|
||||
|
||||
public function getHydrationMode()
|
||||
{
|
||||
return $this->_hydrationMode;
|
||||
}
|
||||
|
||||
public function setHydrationMode($hydrationMode)
|
||||
{
|
||||
$this->_hydrationMode = $hydrationMode;
|
||||
}
|
||||
|
||||
public function getTableToClassAliasMap()
|
||||
{
|
||||
return $this->_tableToClassAliasMap;
|
||||
}
|
||||
|
||||
public function setTableToClassAliasMap(array $map)
|
||||
{
|
||||
$this->_tableToClassAliasMap = $map;
|
||||
}
|
||||
|
||||
public function setQueryComponents(array $queryComponents)
|
||||
{
|
||||
$this->_queryComponents = $queryComponents;
|
||||
}
|
||||
|
||||
public function getQueryComponents()
|
||||
{
|
||||
return $this->_queryComponents;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Doctrine_Record_Filter
|
||||
* Doctrine_Entity_Filter
|
||||
* Filters the record getters and setters
|
||||
*
|
||||
* @package Doctrine
|
||||
@ -46,17 +46,17 @@ abstract class Doctrine_Record_Filter
|
||||
|
||||
/**
|
||||
* filterSet
|
||||
* defines an implementation for filtering the set() method of Doctrine_Record
|
||||
* defines an implementation for filtering the set() method of Doctrine_Entity
|
||||
*
|
||||
* @param mixed $name name of the property or related component
|
||||
*/
|
||||
abstract public function filterSet(Doctrine_Record $record, $name, $value);
|
||||
abstract public function filterSet(Doctrine_Entity $record, $name, $value);
|
||||
|
||||
/**
|
||||
* filterGet
|
||||
* defines an implementation for filtering the get() method of Doctrine_Record
|
||||
* defines an implementation for filtering the get() method of Doctrine_Entity
|
||||
*
|
||||
* @param mixed $name name of the property or related component
|
||||
*/
|
||||
abstract public function filterGet(Doctrine_Record $record, $name);
|
||||
abstract public function filterGet(Doctrine_Entity $record, $name);
|
||||
}
|
@ -48,11 +48,11 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
|
||||
|
||||
/**
|
||||
* filterSet
|
||||
* defines an implementation for filtering the set() method of Doctrine_Record
|
||||
* defines an implementation for filtering the set() method of Doctrine_Entity
|
||||
*
|
||||
* @param mixed $name name of the property or related component
|
||||
*/
|
||||
public function filterSet(Doctrine_Record $record, $name, $value)
|
||||
public function filterSet(Doctrine_Entity $record, $name, $value)
|
||||
{
|
||||
foreach ($this->_aliases as $alias) {
|
||||
if ( ! $record->exists()) {
|
||||
@ -76,11 +76,11 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
|
||||
|
||||
/**
|
||||
* filterGet
|
||||
* defines an implementation for filtering the get() method of Doctrine_Record
|
||||
* defines an implementation for filtering the get() method of Doctrine_Entity
|
||||
*
|
||||
* @param mixed $name name of the property or related component
|
||||
*/
|
||||
public function filterGet(Doctrine_Record $record, $name)
|
||||
public function filterGet(Doctrine_Entity $record, $name)
|
||||
{
|
||||
foreach ($this->_aliases as $alias) {
|
||||
if ( ! $record->exists()) {
|
||||
|
@ -35,22 +35,22 @@ class Doctrine_Record_Filter_Standard extends Doctrine_Record_Filter
|
||||
{
|
||||
/**
|
||||
* filterSet
|
||||
* defines an implementation for filtering the set() method of Doctrine_Record
|
||||
* defines an implementation for filtering the set() method of Doctrine_Entity
|
||||
*
|
||||
* @param mixed $name name of the property or related component
|
||||
*/
|
||||
public function filterSet(Doctrine_Record $record, $name, $value)
|
||||
public function filterSet(Doctrine_Entity $record, $name, $value)
|
||||
{
|
||||
throw new Doctrine_Record_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
|
||||
}
|
||||
|
||||
/**
|
||||
* filterGet
|
||||
* defines an implementation for filtering the get() method of Doctrine_Record
|
||||
* defines an implementation for filtering the get() method of Doctrine_Entity
|
||||
*
|
||||
* @param mixed $name name of the property or related component
|
||||
*/
|
||||
public function filterGet(Doctrine_Record $record, $name)
|
||||
public function filterGet(Doctrine_Entity $record, $name)
|
||||
{
|
||||
throw new Doctrine_Record_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
class Doctrine_Record_Iterator extends ArrayIterator
|
||||
{
|
||||
/**
|
||||
* @var Doctrine_Record $record
|
||||
* @var Doctrine_Entity $record
|
||||
*/
|
||||
private $record;
|
||||
|
||||
@ -45,9 +45,9 @@ class Doctrine_Record_Iterator extends ArrayIterator
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
*/
|
||||
public function __construct(Doctrine_Record $record)
|
||||
public function __construct(Doctrine_Entity $record)
|
||||
{
|
||||
$this->record = $record;
|
||||
parent::__construct($record->getData());
|
||||
|
@ -354,10 +354,10 @@ abstract class Doctrine_Relation implements ArrayAccess
|
||||
*
|
||||
* fetches a component related to given record
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @return Doctrine_Record|Doctrine_Collection
|
||||
* @param Doctrine_Entity $record
|
||||
* @return Doctrine_Entity|Doctrine_Collection
|
||||
*/
|
||||
abstract public function fetchRelatedFor(Doctrine_Record $record);
|
||||
abstract public function fetchRelatedFor(Doctrine_Entity $record);
|
||||
|
||||
/**
|
||||
* __toString
|
||||
|
@ -89,10 +89,10 @@ class Doctrine_Relation_Association extends Doctrine_Relation
|
||||
*
|
||||
* fetches a component related to given record
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @return Doctrine_Record|Doctrine_Collection
|
||||
* @param Doctrine_Entity $record
|
||||
* @return Doctrine_Entity|Doctrine_Collection
|
||||
*/
|
||||
public function fetchRelatedFor(Doctrine_Record $record)
|
||||
public function fetchRelatedFor(Doctrine_Entity $record)
|
||||
{
|
||||
// FIXME: composite key support
|
||||
$ids = $record->identifier();
|
||||
|
@ -74,7 +74,7 @@ class Doctrine_Relation_Association_Self extends Doctrine_Relation_Association
|
||||
return $dql;
|
||||
}
|
||||
|
||||
public function fetchRelatedFor(Doctrine_Record $record)
|
||||
public function fetchRelatedFor(Doctrine_Entity $record)
|
||||
{
|
||||
// FIXME: composite key support
|
||||
$ids = $record->identifier();
|
||||
|
@ -38,10 +38,10 @@ class Doctrine_Relation_ForeignKey extends Doctrine_Relation
|
||||
*
|
||||
* fetches a component related to given record
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @return Doctrine_Record|Doctrine_Collection
|
||||
* @param Doctrine_Entity $record
|
||||
* @return Doctrine_Entity|Doctrine_Collection
|
||||
*/
|
||||
public function fetchRelatedFor(Doctrine_Record $record)
|
||||
public function fetchRelatedFor(Doctrine_Entity $record)
|
||||
{
|
||||
$id = array();
|
||||
$localTable = $record->getTable();
|
||||
|
@ -38,10 +38,10 @@ class Doctrine_Relation_LocalKey extends Doctrine_Relation
|
||||
*
|
||||
* fetches a component related to given record
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @return Doctrine_Record|Doctrine_Collection
|
||||
* @param Doctrine_Entity $record
|
||||
* @return Doctrine_Entity|Doctrine_Collection
|
||||
*/
|
||||
public function fetchRelatedFor(Doctrine_Record $record)
|
||||
public function fetchRelatedFor(Doctrine_Entity $record)
|
||||
{
|
||||
$localFieldName = $record->getTable()->getFieldName($this->definition['local']);
|
||||
$id = $record->get($localFieldName);
|
||||
|
@ -74,7 +74,7 @@ class Doctrine_Relation_Nest extends Doctrine_Relation_Association
|
||||
return $dql;
|
||||
}
|
||||
|
||||
public function fetchRelatedFor(Doctrine_Record $record)
|
||||
public function fetchRelatedFor(Doctrine_Entity $record)
|
||||
{
|
||||
// FIXME: composite key support
|
||||
$ids = $record->identifier();
|
||||
|
@ -96,7 +96,7 @@ class Doctrine_Search extends Doctrine_Record_Generator
|
||||
* updateIndex
|
||||
* updates the index
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return integer
|
||||
*/
|
||||
public function updateIndex(array $data)
|
||||
|
@ -33,7 +33,7 @@
|
||||
class Doctrine_Template
|
||||
{
|
||||
/**
|
||||
* @param Doctrine_Record $_invoker the record that invoked the last delegated call
|
||||
* @param Doctrine_Entity $_invoker the record that invoked the last delegated call
|
||||
*/
|
||||
protected $_invoker;
|
||||
|
||||
@ -66,10 +66,10 @@ class Doctrine_Template
|
||||
*
|
||||
* sets the last used invoker
|
||||
*
|
||||
* @param Doctrine_Record $invoker the record that invoked the last delegated call
|
||||
* @param Doctrine_Entity $invoker the record that invoked the last delegated call
|
||||
* @return Doctrine_Template this object
|
||||
*/
|
||||
public function setInvoker(Doctrine_Record $invoker)
|
||||
public function setInvoker(Doctrine_Entity $invoker)
|
||||
{
|
||||
$this->_invoker = $invoker;
|
||||
}
|
||||
@ -78,7 +78,7 @@ class Doctrine_Template
|
||||
* setInvoker
|
||||
* returns the last used invoker
|
||||
*
|
||||
* @return Doctrine_Record the record that invoked the last delegated call
|
||||
* @return Doctrine_Entity the record that invoked the last delegated call
|
||||
*/
|
||||
public function getInvoker()
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ class Doctrine_Template_Geographical extends Doctrine_Template
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getDistance(Doctrine_Record $record, $kilometers = false)
|
||||
public function getDistance(Doctrine_Entity $record, $kilometers = false)
|
||||
{
|
||||
$query = $this->getDistanceQuery($kilometers);
|
||||
|
||||
|
@ -129,12 +129,12 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
|
||||
* addInvalid
|
||||
* adds record into invalid records list
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return boolean false if record already existed in invalid records list,
|
||||
* otherwise true
|
||||
* @todo package:orm
|
||||
*/
|
||||
public function addInvalid(Doctrine_Record $record)
|
||||
public function addInvalid(Doctrine_Entity $record)
|
||||
{
|
||||
if (in_array($record, $this->invalid, true)) {
|
||||
return false;
|
||||
|
@ -35,14 +35,14 @@ interface Doctrine_Tree_Interface {
|
||||
/**
|
||||
* creates root node from given record or from a new record
|
||||
*
|
||||
* @param object $record instance of Doctrine_Record
|
||||
* @param object $record instance of Doctrine_Entity
|
||||
*/
|
||||
public function createRoot(Doctrine_Record $record = null);
|
||||
public function createRoot(Doctrine_Entity $record = null);
|
||||
|
||||
/**
|
||||
* returns root node
|
||||
*
|
||||
* @return object $record instance of Doctrine_Record
|
||||
* @return object $record instance of Doctrine_Entity
|
||||
*/
|
||||
public function findRoot($root_id = 1);
|
||||
|
||||
|
@ -71,9 +71,9 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
|
||||
/**
|
||||
* creates root node from given record or from a new record
|
||||
*
|
||||
* @param object $record instance of Doctrine_Record
|
||||
* @param object $record instance of Doctrine_Entity
|
||||
*/
|
||||
public function createRoot(Doctrine_Record $record = null)
|
||||
public function createRoot(Doctrine_Entity $record = null)
|
||||
{
|
||||
if ( ! $record) {
|
||||
$record = $this->table->create();
|
||||
@ -96,7 +96,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
|
||||
/**
|
||||
* returns root node
|
||||
*
|
||||
* @return object $record instance of Doctrine_Record
|
||||
* @return object $record instance of Doctrine_Entity
|
||||
* @deprecated Use fetchRoot()
|
||||
*/
|
||||
public function findRoot($rootId = 1)
|
||||
@ -178,7 +178,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
|
||||
public function fetchBranch($pk, $options = array())
|
||||
{
|
||||
$record = $this->table->find($pk);
|
||||
if ( ! ($record instanceof Doctrine_Record) || !$record->exists()) {
|
||||
if ( ! ($record instanceof Doctrine_Entity) || !$record->exists()) {
|
||||
// TODO: if record doesn't exist, throw exception or similar?
|
||||
return false;
|
||||
}
|
||||
|
@ -65,10 +65,10 @@ class Doctrine_Validator
|
||||
* validates a given record and saves possible errors
|
||||
* in Doctrine_Validator::$stack
|
||||
*
|
||||
* @param Doctrine_Record $record
|
||||
* @param Doctrine_Entity $record
|
||||
* @return void
|
||||
*/
|
||||
public function validateRecord(Doctrine_Record $record)
|
||||
public function validateRecord(Doctrine_Entity $record)
|
||||
{
|
||||
$classMetadata = $record->getTable();
|
||||
$columns = $record->getTable()->getColumns();
|
||||
@ -83,7 +83,7 @@ class Doctrine_Validator
|
||||
foreach ($fields as $fieldName => $value) {
|
||||
if ($value === Doctrine_Null::$INSTANCE) {
|
||||
$value = null;
|
||||
} else if ($value instanceof Doctrine_Record) {
|
||||
} else if ($value instanceof Doctrine_Entity) {
|
||||
$ids = $value->identifier();
|
||||
$value = count($ids) > 0 ? array_pop($ids) : null;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class Doctrine_Validator_Unique
|
||||
// unique value already exists in the database IF the record in the database is the same
|
||||
// as the one that is validated here.
|
||||
$state = $this->invoker->state();
|
||||
if ( ! ($state == Doctrine_Record::STATE_TDIRTY || $state == Doctrine_Record::STATE_TCLEAN)) {
|
||||
if ( ! ($state == Doctrine_Entity::STATE_TDIRTY || $state == Doctrine_Entity::STATE_TCLEAN)) {
|
||||
foreach ((array) $table->getIdentifier() as $pk) {
|
||||
$sql .= " AND {$pk} != ?";
|
||||
$values[] = $this->invoker->$pk;
|
||||
|
@ -146,7 +146,7 @@ class Doctrine_View
|
||||
/**
|
||||
* execute
|
||||
* executes the view
|
||||
* returns a collection of Doctrine_Record objects
|
||||
* returns a collection of Doctrine_Entity objects
|
||||
*
|
||||
* @return Doctrine_Collection
|
||||
*/
|
||||
|
@ -4,9 +4,12 @@ require_once 'lib/mocks/Doctrine_HydratorMockStatement.php';
|
||||
|
||||
class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
{
|
||||
private $_em;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->_em = $this->sharedFixture['connection'];
|
||||
}
|
||||
|
||||
/** Getter for the hydration mode dataProvider */
|
||||
@ -18,13 +21,26 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/** Helper method */
|
||||
private function _createParserResult($stmt, $queryComponents, $tableToClassAliasMap,
|
||||
$hydrationMode, $isMixedQuery = false)
|
||||
{
|
||||
$parserResult = new Doctrine_Query_ParserResultDummy();
|
||||
$parserResult->setDatabaseStatement($stmt);
|
||||
$parserResult->setHydrationMode($hydrationMode);
|
||||
$parserResult->setQueryComponents($queryComponents);
|
||||
$parserResult->setTableToClassAliasMap($tableToClassAliasMap);
|
||||
$parserResult->setMixedQuery($isMixedQuery);
|
||||
return $parserResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select u.id, u.name from CmsUser u
|
||||
*
|
||||
* @dataProvider hydrationModeProvider
|
||||
*/
|
||||
public function testNewHydrationSimpleEntityQuery($hydrationMode)
|
||||
{
|
||||
{
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'u' => array(
|
||||
@ -55,10 +71,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
|
||||
|
||||
$stmt = new Doctrine_HydratorMockStatement($resultSet);
|
||||
$hydrator = new Doctrine_HydratorNew();
|
||||
$hydrator->setQueryComponents($queryComponents);
|
||||
$hydrator = new Doctrine_HydratorNew($this->_em);
|
||||
|
||||
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
|
||||
$result = $hydrator->hydrateResultSet($this->_createParserResult(
|
||||
$stmt, $queryComponents, $tableAliasMap, $hydrationMode));
|
||||
|
||||
$this->assertEquals(2, count($result));
|
||||
$this->assertEquals(1, $result[0]['id']);
|
||||
@ -68,8 +84,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
|
||||
$this->assertTrue($result instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1] instanceof Doctrine_Entity);
|
||||
} else {
|
||||
$this->assertTrue(is_array($result));
|
||||
}
|
||||
@ -135,12 +151,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
);
|
||||
|
||||
$stmt = new Doctrine_HydratorMockStatement($resultSet);
|
||||
$hydrator = new Doctrine_HydratorNew();
|
||||
$hydrator->setQueryComponents($queryComponents);
|
||||
$hydrator = new Doctrine_HydratorNew($this->_em);
|
||||
|
||||
$hydrator->setResultMixed(true);
|
||||
|
||||
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
|
||||
$result = $hydrator->hydrateResultSet($this->_createParserResult(
|
||||
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
|
||||
//var_dump($result);
|
||||
|
||||
$this->assertEquals(2, count($result));
|
||||
@ -161,11 +175,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
$this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']);
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
|
||||
$this->assertTrue($result[0][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
|
||||
}
|
||||
}
|
||||
@ -223,12 +237,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
|
||||
|
||||
$stmt = new Doctrine_HydratorMockStatement($resultSet);
|
||||
$hydrator = new Doctrine_HydratorNew();
|
||||
$hydrator->setQueryComponents($queryComponents);
|
||||
$hydrator = new Doctrine_HydratorNew($this->_em);
|
||||
|
||||
$hydrator->setResultMixed(true);
|
||||
|
||||
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
|
||||
$result = $hydrator->hydrateResultSet($this->_createParserResult(
|
||||
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
|
||||
//var_dump($result);
|
||||
|
||||
$this->assertEquals(2, count($result));
|
||||
@ -242,8 +254,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
$this->assertEquals(1, $result[1]['numPhones']);
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
|
||||
$this->assertTrue($result[0][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0] instanceof Doctrine_Entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,13 +320,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
|
||||
|
||||
$stmt = new Doctrine_HydratorMockStatement($resultSet);
|
||||
$hydrator = new Doctrine_HydratorNew();
|
||||
$hydrator->setQueryComponents($queryComponents);
|
||||
$hydrator = new Doctrine_HydratorNew($this->_em);
|
||||
|
||||
// give the hydrator an artificial hint
|
||||
$hydrator->setResultMixed(true);
|
||||
|
||||
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
|
||||
$result = $hydrator->hydrateResultSet($this->_createParserResult(
|
||||
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
|
||||
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
|
||||
//var_dump($result);
|
||||
}
|
||||
@ -340,8 +349,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
$this->assertEquals('JWAGE', $result[1]['nameUpper']);
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
|
||||
$this->assertTrue($result[0]['1'] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1]['2'] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0]['1'] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1]['2'] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0]['1']['phonenumbers'] instanceof Doctrine_Collection);
|
||||
$this->assertEquals(2, count($result[0]['1']['phonenumbers']));
|
||||
}
|
||||
@ -450,12 +459,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
);
|
||||
|
||||
$stmt = new Doctrine_HydratorMockStatement($resultSet);
|
||||
$hydrator = new Doctrine_HydratorNew();
|
||||
$hydrator->setQueryComponents($queryComponents);
|
||||
$hydrator = new Doctrine_HydratorNew($this->_em);
|
||||
|
||||
$hydrator->setResultMixed(true);
|
||||
|
||||
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
|
||||
$result = $hydrator->hydrateResultSet($this->_createParserResult(
|
||||
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
|
||||
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
|
||||
//var_dump($result);
|
||||
}
|
||||
@ -484,18 +491,18 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
$this->assertEquals('PHP6', $result[1][0]['articles'][1]['topic']);
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
|
||||
$this->assertTrue($result[0][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,12 +632,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
);
|
||||
|
||||
$stmt = new Doctrine_HydratorMockStatement($resultSet);
|
||||
$hydrator = new Doctrine_HydratorNew();
|
||||
$hydrator->setQueryComponents($queryComponents);
|
||||
$hydrator = new Doctrine_HydratorNew($this->_em);
|
||||
|
||||
$hydrator->setResultMixed(true);
|
||||
|
||||
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
|
||||
$result = $hydrator->hydrateResultSet($this->_createParserResult(
|
||||
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
|
||||
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
|
||||
//var_dump($result);
|
||||
}
|
||||
@ -667,23 +672,23 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
$this->assertFalse(isset($result[1][0]['articles'][1]['comments']));
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
|
||||
$this->assertTrue($result[0][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0] instanceof Doctrine_Entity);
|
||||
// phonenumbers
|
||||
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Entity);
|
||||
// articles
|
||||
$this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Entity);
|
||||
// article comments
|
||||
$this->assertTrue($result[0][0]['articles'][0]['comments'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -772,12 +777,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
);
|
||||
|
||||
$stmt = new Doctrine_HydratorMockStatement($resultSet);
|
||||
$hydrator = new Doctrine_HydratorNew();
|
||||
$hydrator->setQueryComponents($queryComponents);
|
||||
$hydrator = new Doctrine_HydratorNew($this->_em);
|
||||
|
||||
//$hydrator->setResultMixed(true);
|
||||
|
||||
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
|
||||
$result = $hydrator->hydrateResultSet($this->_createParserResult(
|
||||
$stmt, $queryComponents, $tableAliasMap, $hydrationMode));
|
||||
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
|
||||
//var_dump($result);
|
||||
}
|
||||
@ -794,9 +797,9 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
$this->assertTrue(is_array($result[1]));
|
||||
} else {
|
||||
$this->assertTrue($result instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[1] instanceof Doctrine_Record);
|
||||
$this->assertTrue($result[0] instanceof Doctrine_Entity);
|
||||
$this->assertTrue($result[1] instanceof Doctrine_Entity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class Orm_UnitOfWorkTestCase extends Doctrine_OrmTestCase
|
||||
{
|
||||
$this->_user->username = 'romanb';
|
||||
$this->_user->id = 1;
|
||||
$this->assertEquals(Doctrine_Record::STATE_TDIRTY, $this->_user->state());
|
||||
$this->assertEquals(Doctrine_Entity::STATE_TDIRTY, $this->_user->state());
|
||||
$this->assertFalse($this->_unitOfWork->contains($this->_user));
|
||||
$this->_unitOfWork->registerDirty($this->_user);
|
||||
$this->assertTrue($this->_unitOfWork->isRegisteredDirty($this->_user));
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class CmsArticle extends Doctrine_Record
|
||||
class CmsArticle extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class CmsComment extends Doctrine_Record
|
||||
class CmsComment extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class CmsPhonenumber extends Doctrine_Record
|
||||
class CmsPhonenumber extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class CmsUser extends Doctrine_Record
|
||||
class CmsUser extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class ForumBoard extends Doctrine_Record {
|
||||
class ForumBoard extends Doctrine_Entity {
|
||||
public static function initMetadata($class) {
|
||||
$class->mapColumn('position', 'integer');
|
||||
$class->mapColumn('category_id', 'integer');
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class ForumCategory extends Doctrine_Record {
|
||||
class ForumCategory extends Doctrine_Entity {
|
||||
public static function initMetadata($class) {
|
||||
$class->mapColumn('position', 'integer');
|
||||
$class->mapColumn('name', 'string', 255);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class ForumUser extends Doctrine_Record
|
||||
class ForumUser extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ class Doctrine_Cache_FileTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($this->cache->exists(4));
|
||||
|
||||
$record = $this->cache->fetch(4);
|
||||
$this->assertTrue($record instanceof Doctrine_Record);
|
||||
$this->assertTrue($record instanceof Doctrine_Entity);
|
||||
$this->assertTrue($record->obtainIdentifier() == $this->old->obtainIdentifier());
|
||||
|
||||
$this->assertTrue($this->cache->getTable() == $this->objTable);
|
||||
|
@ -21,7 +21,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($this->cache->store($this->objTable->find(4)));
|
||||
|
||||
$record = $this->cache->fetch(4);
|
||||
$this->assertTrue($record instanceof Doctrine_Record);
|
||||
$this->assertTrue($record instanceof Doctrine_Entity);
|
||||
|
||||
foreach($this->old as $name => $value) {
|
||||
$this->assertEqual($record->get($name), $value);
|
||||
@ -36,7 +36,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
|
||||
$array = $this->cache->fetchMultiple(array(5,6));
|
||||
$this->assertEqual(gettype($array), "array");
|
||||
$this->assertEqual(count($array), 1);
|
||||
$this->assertTrue($array[0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($array[0] instanceof Doctrine_Entity);
|
||||
}
|
||||
public function testDeleteMultiple() {
|
||||
$this->assertEqual($this->cache->deleteMultiple(array()),0);
|
||||
@ -52,7 +52,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
public function testDelete() {
|
||||
$this->cache->store($this->objTable->find(5));
|
||||
$this->assertTrue($this->cache->fetch(5) instanceof Doctrine_Record);
|
||||
$this->assertTrue($this->cache->fetch(5) instanceof Doctrine_Entity);
|
||||
|
||||
$this->assertEqual($this->cache->delete(5),true);
|
||||
$this->assertFalse($this->cache->fetch(5));
|
||||
|
@ -225,7 +225,7 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
|
||||
$this->conn->addListener(new Doctrine_EventListener());
|
||||
}
|
||||
}
|
||||
class CTITestParent1 extends Doctrine_Record
|
||||
class CTITestParent1 extends Doctrine_Entity
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
@ -265,7 +265,7 @@ class CTITest extends CTITestParent4
|
||||
}
|
||||
}
|
||||
|
||||
class CTITestOneToManyRelated extends Doctrine_Record
|
||||
class CTITestOneToManyRelated extends Doctrine_Entity
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
|
@ -8,16 +8,16 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual(count($users), 5);
|
||||
$users[5];
|
||||
|
||||
$this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[5]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
$users[5];
|
||||
|
||||
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
|
||||
|
||||
$users = $this->connection->query("FROM User-o");
|
||||
$this->assertEqual(count($users), 3);
|
||||
$this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[1]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[2]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[0]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($users[1]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($users[2]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
// indexes 0,1,2 in use
|
||||
|
||||
$users[7];
|
||||
@ -28,15 +28,15 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($users->contains(6));
|
||||
$this->assertTrue($users->contains(7));
|
||||
|
||||
$this->assertEqual($users[6]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[7]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[6]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($users[7]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
|
||||
$users[5];
|
||||
$this->assertEqual(count($users), 8);
|
||||
$this->assertEqual($users[3]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[4]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[3]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($users[4]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($users[5]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
|
||||
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 1);
|
||||
@ -61,8 +61,8 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
|
||||
foreach($coll as $user) {
|
||||
}
|
||||
$this->assertEqual($coll->count(), 8);
|
||||
$this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($coll[3]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($coll[6]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
|
||||
|
||||
@ -71,7 +71,7 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
|
||||
foreach($coll as $user) {
|
||||
}
|
||||
$this->assertEqual($coll->count(), 8);
|
||||
$this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($coll[3]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($coll[6]->getState(), Doctrine_Entity::STATE_CLEAN);
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual(count($coll), 3);
|
||||
|
||||
$this->assertEqual($coll[2]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($coll[2]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
|
||||
|
||||
|
||||
@ -287,8 +287,8 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertFalse($users->contains(0));
|
||||
$this->assertEqual($users->count(), 8);
|
||||
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($users[4]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
$this->assertEqual($users[4]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
}
|
||||
public function testFetchCollectionWithNameAsIndex()
|
||||
{
|
||||
@ -299,8 +299,8 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertFalse($users->contains(0));
|
||||
$this->assertEqual($users->count(), 8);
|
||||
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($users['zYne']->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
$this->assertEqual($users['zYne']->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
}
|
||||
public function testFetchMultipleCollections()
|
||||
{
|
||||
@ -317,16 +317,16 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertFalse($users->contains(0));
|
||||
$this->assertEqual($users->count(), 8);
|
||||
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($users[2]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($users[3]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($users[4]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
$this->assertEqual($users[2]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
$this->assertEqual($users[3]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
$this->assertEqual($users[4]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($users[4]->name, 'zYne');
|
||||
|
||||
$this->assertEqual($users[4]->Phonenumber[0]->exists(), false);
|
||||
$this->assertEqual($users[4]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($users[4]->Phonenumber[0]->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
$this->assertEqual($users[4]->Phonenumber[1]->exists(), false);
|
||||
$this->assertEqual($users[4]->Phonenumber[2]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[4]->Phonenumber[2]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
//$user = $this->connection->create('User');
|
||||
//$this->connection->unitOfWork->delete($user);
|
||||
//$this->assertEqual($user->state(),Doctrine_Record::STATE_TCLEAN);
|
||||
//$this->assertEqual($user->state(),Doctrine_Entity::STATE_TCLEAN);
|
||||
}
|
||||
|
||||
public function testGetTable()
|
||||
|
@ -34,7 +34,7 @@ class Doctrine_CtiColumnAggregation_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
|
||||
}
|
||||
abstract class CTICAAbstractBase extends Doctrine_Record
|
||||
abstract class CTICAAbstractBase extends Doctrine_Entity
|
||||
{ }
|
||||
class CTICATestParent1 extends CTICAAbstractBase
|
||||
{
|
||||
@ -85,7 +85,7 @@ class CTICATest2 extends CTICATestParent2
|
||||
}
|
||||
}
|
||||
|
||||
class CTICATestOneToManyRelated extends Doctrine_Record
|
||||
class CTICATestOneToManyRelated extends Doctrine_Entity
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ class Doctrine_CustomPrimaryKey_TestCase extends Doctrine_UnitTestCase
|
||||
public function testOperations()
|
||||
{
|
||||
$c = new CustomPK();
|
||||
$this->assertTrue($c instanceof Doctrine_Record);
|
||||
$this->assertTrue($c instanceof Doctrine_Entity);
|
||||
|
||||
$c->name = 'custom pk test';
|
||||
$this->assertEqual($c->identifier(), array());
|
||||
|
@ -42,7 +42,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
|
||||
$test->is_working = false;
|
||||
|
||||
$this->assertIdentical($test->is_working, false);
|
||||
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
$test->save();
|
||||
|
||||
$test->refresh();
|
||||
@ -98,7 +98,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->is_working = null;
|
||||
|
||||
$this->assertIdentical($this->is_working, null);
|
||||
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
$test->save();
|
||||
|
||||
$test->refresh();
|
||||
@ -108,7 +108,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->is_working_notnull = null;
|
||||
|
||||
$this->assertIdentical($this->is_working_notnull, null);
|
||||
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
$test->save();
|
||||
|
||||
$test->refresh();
|
||||
|
@ -110,7 +110,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertEqual($users[0]['Email']['address'], 'zYne@example.com');
|
||||
$this->assertTrue($users[0] instanceof User);
|
||||
$this->assertTrue($users instanceof Doctrine_Collection);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($users[0]->id, 4);
|
||||
|
||||
$this->assertTrue($users[0]['Email'] instanceof Email);
|
||||
@ -128,7 +128,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual(count($users), 8);
|
||||
$this->assertTrue($users[0] instanceof User);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertTrue($users instanceof Doctrine_Collection);
|
||||
$this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
|
||||
}
|
||||
@ -143,7 +143,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual(count($users), 8);
|
||||
$this->assertTrue($users[0] instanceof User);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
|
||||
$this->assertEqual($this->conn->count(), $count + 1);
|
||||
|
@ -101,7 +101,7 @@ class Doctrine_Hydrate_Mock extends Doctrine_Hydrator_Abstract
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null)
|
||||
public function hydrateResultSet($parserResult)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ class Doctrine_Inheritance_Joined_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
|
||||
|
||||
class CTI_User extends Doctrine_Record
|
||||
class CTI_User extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ class Doctrine_Inheritance_SingleTable_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
|
||||
|
||||
class STI_User extends Doctrine_Record
|
||||
class STI_User extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ class Doctrine_Inheritance_TablePerClass_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
|
||||
|
||||
class CCTI_User extends Doctrine_Record
|
||||
class CCTI_User extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
|
||||
|
||||
class Metadata_User extends Doctrine_Record
|
||||
class Metadata_User extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata(Doctrine_ClassMetadata $class)
|
||||
{
|
||||
@ -195,7 +195,7 @@ class Metadata_SuperManager extends Metadata_Manager
|
||||
|
||||
|
||||
|
||||
class Metadata_STI_User extends Doctrine_Record
|
||||
class Metadata_STI_User extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ class Doctrine_PessimisticLocking_TestCase extends Doctrine_UnitTestCase {
|
||||
* Tests the retrieving of a lock's owner.
|
||||
* This test implicitly tests getLock().
|
||||
*
|
||||
* @param Doctrine_Record $lockedRecord
|
||||
* @param Doctrine_Entity $lockedRecord
|
||||
*/
|
||||
public function testGetLockOwner() {
|
||||
$entries = $this->connection->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
|
||||
|
@ -59,7 +59,7 @@ class Doctrine_Plugin_TestCase extends Doctrine_UnitTestCase
|
||||
public function testCreatingNewRecordsInvokesAllPlugins()
|
||||
{
|
||||
$wiki = new Wiki();
|
||||
$wiki->state(Doctrine_Record::STATE_TDIRTY);
|
||||
$wiki->state(Doctrine_Entity::STATE_TDIRTY);
|
||||
$wiki->save();
|
||||
|
||||
$fi = $wiki->Translation['FI'];
|
||||
@ -86,7 +86,7 @@ class Doctrine_Plugin_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertEqual($wiki->Translation['FI']->version, 2);
|
||||
}
|
||||
}
|
||||
class Wiki extends Doctrine_Record
|
||||
class Wiki extends Doctrine_Entity
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($users->count(), 1);
|
||||
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
}
|
||||
|
||||
public function testAggregateValueIsMappedToRecord()
|
||||
@ -105,8 +105,8 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($users->count(), 2);
|
||||
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($users[1]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
$this->assertEqual($users[1]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
|
||||
$this->assertEqual($users[0]->count, 2);
|
||||
$this->assertEqual($users[1]->count, 2);
|
||||
@ -122,8 +122,8 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($users->count(), 2);
|
||||
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($users[1]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
$this->assertEqual($users[1]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
|
||||
$this->assertEqual($users[0]->count, 2);
|
||||
$this->assertEqual($users[1]->count, 2);
|
||||
|
@ -293,7 +293,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$users = $q->execute();
|
||||
|
||||
$this->assertEqual($users[0]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($users[0]->Phonenumber[0]->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
|
||||
$this->assertEqual($users[0]->Phonenumber[0]->count, 1);
|
||||
$this->assertEqual($users[1]->Phonenumber[0]->count, 3);
|
||||
|
@ -84,8 +84,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($coll->count(), 11);
|
||||
|
||||
$this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($coll[3]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
$this->assertEqual($coll[3]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
}
|
||||
public function testSmartMapping()
|
||||
{
|
||||
@ -101,8 +101,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($coll->count(), 11);
|
||||
|
||||
$this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($coll[3]->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
$this->assertEqual($coll[3]->state(), Doctrine_Entity::STATE_PROXY);
|
||||
}
|
||||
|
||||
public function testMultipleComponents()
|
||||
|
@ -84,7 +84,7 @@ class Doctrine_Record_Filter_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
}
|
||||
}
|
||||
class CompositeRecord extends Doctrine_Record
|
||||
class CompositeRecord extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
@ -94,7 +94,7 @@ class CompositeRecord extends Doctrine_Record
|
||||
$class->unshiftFilter(new Doctrine_Record_Filter_Compound(array('Related')));
|
||||
}
|
||||
}
|
||||
class RelatedCompositeRecord extends Doctrine_Record
|
||||
class RelatedCompositeRecord extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -90,11 +90,11 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertEqual($r->something, 'something');
|
||||
|
||||
$this->assertEqual($r->deleted, null);
|
||||
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($r->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
try {
|
||||
$r->delete();
|
||||
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($r->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($r->deleted, true);
|
||||
} catch(Doctrine_Exception $e) {
|
||||
$this->fail();
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Doctrine_Record_Inheritance_TestCase
|
||||
*
|
||||
* This test case demonstrates the use of inheritance involving subclasses of
|
||||
* Doctrine_Record. This type of inheritance is heavily used in sfDoctrine,
|
||||
* Doctrine_Entity. This type of inheritance is heavily used in sfDoctrine,
|
||||
* and as new inheritance-related features get added to Doctrine it seems to
|
||||
* be an area where subtle breakage can sneak in.
|
||||
*
|
||||
@ -49,7 +49,7 @@ class Doctrine_Record_Inheritance_TestCase extends Doctrine_UnitTestCase
|
||||
// does it have the appropriate parentage?
|
||||
$this->assertTrue($record instanceof PluginSymfonyRecord);
|
||||
$this->assertTrue($record instanceof BaseSymfonyRecord);
|
||||
$this->assertTrue($record instanceof Doctrine_Record);
|
||||
$this->assertTrue($record instanceof Doctrine_Entity);
|
||||
|
||||
// does it have the expected data?
|
||||
$this->assertEqual($record['name'], 'Test me');
|
||||
|
@ -90,79 +90,79 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
|
||||
} catch(Doctrine_Record_State_Exception $e) {
|
||||
$this->pass();
|
||||
}
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
try {
|
||||
$user->state('some unknown state');
|
||||
$this->fail();
|
||||
} catch(Doctrine_Record_State_Exception $e) {
|
||||
} catch(Doctrine_Entity_State_Exception $e) {
|
||||
$this->pass();
|
||||
}
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
}
|
||||
|
||||
public function testAssignDirtyState()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$user->state(Doctrine_Record::STATE_DIRTY);
|
||||
$user->state(Doctrine_Entity::STATE_DIRTY);
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_DIRTY);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_DIRTY);
|
||||
|
||||
$user->state('dirty');
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_DIRTY);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_DIRTY);
|
||||
}
|
||||
|
||||
public function testAssignCleanState()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$user->state(Doctrine_Record::STATE_CLEAN);
|
||||
$user->state(Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$user->state('clean');
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
}
|
||||
|
||||
public function testAssignTransientCleanState()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$user->state(Doctrine_Record::STATE_TCLEAN);
|
||||
$user->state(Doctrine_Entity::STATE_TCLEAN);
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
|
||||
$user->state('tclean');
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
}
|
||||
|
||||
public function testAssignTransientDirtyState()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$user->state(Doctrine_Record::STATE_TDIRTY);
|
||||
$user->state(Doctrine_Entity::STATE_TDIRTY);
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
|
||||
$user->state('tdirty');
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
}
|
||||
|
||||
public function testAssignProxyState()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$user->state(Doctrine_Record::STATE_PROXY);
|
||||
$user->state(Doctrine_Entity::STATE_PROXY);
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
|
||||
|
||||
$user->state('proxy');
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
|
||||
}
|
||||
|
||||
public function testProxiesAreAutomaticallyUpdatedWithFetches()
|
||||
@ -176,7 +176,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$user = $this->connection->queryOne("SELECT u.name FROM User u WHERE u.name = 'someuser'");
|
||||
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
|
||||
|
||||
$user2 = $this->connection->queryOne("FROM User u WHERE u.name = 'someuser'");
|
||||
|
||||
@ -208,7 +208,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
// to make sure it is saved correctly
|
||||
$user1 = $this->connection->queryOne("FROM User u WHERE u.name = '" . UNAME . "'");
|
||||
$this->assertEqual($user1->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($user1->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($user1->name,UNAME) ;
|
||||
$this->assertEqual($user1->password,UPWD1) ;
|
||||
$this->assertEqual($user1->loginname,ULNAME) ;
|
||||
@ -222,7 +222,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
|
||||
$user2 = $this->connection->queryOne("SELECT u.name FROM User u WHERE u.name = '" . UNAME . "'");
|
||||
|
||||
// the object should be in state proxy with only 'name' fetched ...
|
||||
$this->assertEqual($user2->state(), Doctrine_Record::STATE_PROXY);
|
||||
$this->assertEqual($user2->state(), Doctrine_Entity::STATE_PROXY);
|
||||
$this->assertEqual($user2->name,UNAME) ;
|
||||
$this->assertEqual($user2->password,null) ;
|
||||
$this->assertEqual($user2->loginname,null) ;
|
||||
@ -231,7 +231,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
|
||||
$user2->password = UPWD2 ;
|
||||
|
||||
// now it should be dirty (but may be PDIRTY ... ?)
|
||||
$this->assertEqual($user2->state(),Doctrine_Record::STATE_DIRTY) ;
|
||||
$this->assertEqual($user2->state(),Doctrine_Entity::STATE_DIRTY) ;
|
||||
$this->assertEqual($user2->name,UNAME) ;
|
||||
$this->assertEqual($user2->password,UPWD2) ;
|
||||
$this->assertEqual($user2->loginname,null) ;
|
||||
@ -240,11 +240,11 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
|
||||
$user2->save() ;
|
||||
|
||||
// the logic would suggest the object to go back to PROXY mode (becausse $user2->loginname is null aka not sync with DB)
|
||||
$boolState = ($user2->loginname == null) && ($user2->state() === Doctrine_Record::STATE_PROXY) ;
|
||||
$boolState = ($user2->loginname == null) && ($user2->state() === Doctrine_Entity::STATE_PROXY) ;
|
||||
// this one will currently fail
|
||||
$this->assertTrue($boolState) ;
|
||||
// this will also currently fail (becausse it currently goes back to STATE_CLEAN, which shouldnt be the case)
|
||||
//$this->assertEqual($user2->state(), Doctrine_Record::STATE_PROXY);
|
||||
//$this->assertEqual($user2->state(), Doctrine_Entity::STATE_PROXY);
|
||||
$this->assertEqual($user2->name,UNAME) ;
|
||||
$this->assertEqual($user2->password,UPWD2) ;
|
||||
$this->assertEqual($user2->loginname,null) ;
|
||||
|
@ -55,7 +55,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
$account = $user->Account;
|
||||
$account->amount = 1000;
|
||||
$this->assertTrue($account instanceof Account);
|
||||
$this->assertEqual($account->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($account->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
$this->assertEqual($account->entity_id->getOid(), $user->getOid());
|
||||
$this->assertEqual($account->amount, 1000);
|
||||
$this->assertEqual($user->name, "Richard Linklater");
|
||||
@ -67,7 +67,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$account = $user->Account;
|
||||
$this->assertTrue($account instanceof Account);
|
||||
$this->assertEqual($account->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($account->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($account->entity_id, $user->id);
|
||||
$this->assertEqual($account->amount, 1000);
|
||||
$this->assertEqual($user->name, "Richard Linklater");
|
||||
@ -80,7 +80,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
|
||||
$this->connection->unitOfWork->saveAll();
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertTrue($account instanceof Account);
|
||||
|
||||
$this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
|
||||
@ -90,13 +90,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
|
||||
$user = $user->getRepository()->find($user->id);
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
|
||||
$account = $user->Account;
|
||||
$this->assertTrue($account instanceof Account);
|
||||
|
||||
$this->assertEqual($account->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($account->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
|
||||
|
||||
$this->assertEqual($account->entity_id, $user->id);
|
||||
@ -272,23 +272,23 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertEqual((array)$record->getTable()->getIdentifier(), array("entity1","entity2"));
|
||||
$this->assertEqual($record->getTable()->getIdentifierType(), Doctrine::IDENTIFIER_COMPOSITE);
|
||||
$this->assertEqual($record->identifier(), array("entity1" => null, "entity2" => null));
|
||||
$this->assertEqual($record->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($record->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
|
||||
$record->entity1 = 3;
|
||||
$record->entity2 = 4;
|
||||
$this->assertEqual($record->entity2, 4);
|
||||
$this->assertEqual($record->entity1, 3);
|
||||
$this->assertEqual($record->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($record->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
$this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
|
||||
|
||||
$record->save();
|
||||
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($record->entity2, 4);
|
||||
$this->assertEqual($record->entity1, 3);
|
||||
$this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
|
||||
|
||||
$record = $record->getRepository()->find($record->identifier());
|
||||
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($record->entity2, 4);
|
||||
$this->assertEqual($record->entity1, 3);
|
||||
|
||||
@ -296,26 +296,26 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$record->entity2 = 5;
|
||||
$record->entity1 = 2;
|
||||
$this->assertEqual($record->state(), Doctrine_Record::STATE_DIRTY);
|
||||
$this->assertEqual($record->state(), Doctrine_Entity::STATE_DIRTY);
|
||||
$this->assertEqual($record->entity2, 5);
|
||||
$this->assertEqual($record->entity1, 2);
|
||||
$this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
|
||||
|
||||
$record->save();
|
||||
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($record->entity2, 5);
|
||||
$this->assertEqual($record->entity1, 2);
|
||||
$this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
|
||||
$record = $record->getRepository()->find($record->identifier());
|
||||
|
||||
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($record->entity2, 5);
|
||||
$this->assertEqual($record->entity1, 2);
|
||||
$this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
|
||||
|
||||
$record->refresh();
|
||||
|
||||
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($record->entity2, 5);
|
||||
$this->assertEqual($record->entity1, 2);
|
||||
$this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
|
||||
@ -327,9 +327,9 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$coll = $this->connection->query("FROM EntityReference");
|
||||
$this->assertTrue($coll[0] instanceof EntityReference);
|
||||
$this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertTrue($coll[1] instanceof EntityReference);
|
||||
$this->assertEqual($coll[1]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($coll[1]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$coll = $this->connection->query("FROM EntityReference WHERE EntityReference.entity2 = 5");
|
||||
$this->assertEqual($coll->count(), 1);
|
||||
@ -351,12 +351,12 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$task = new Task();
|
||||
$this->assertTrue($task instanceof Task);
|
||||
$this->assertEqual($task->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($task->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
$this->assertTrue($task->Subtask[0] instanceof Task);
|
||||
|
||||
//$this->assertEqual($task->Subtask[0]->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
//$this->assertEqual($task->Subtask[0]->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
$this->assertTrue($task->ResourceAlias[0] instanceof Resource);
|
||||
$this->assertEqual($task->ResourceAlias[0]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($task->ResourceAlias[0]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
|
||||
$task->name = "Task 1";
|
||||
$task->ResourceAlias[0]->name = "Resource 1";
|
||||
@ -398,13 +398,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
$table = $this->connection->getClassMetadata("User");
|
||||
|
||||
$user = new User();
|
||||
$this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->state()), Doctrine_Lib::getRecordStateAsString(Doctrine_Record::STATE_TCLEAN));
|
||||
$this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->state()), Doctrine_Lib::getRecordStateAsString(Doctrine_Entity::STATE_TCLEAN));
|
||||
$user->name = "John Locke";
|
||||
|
||||
$this->assertTrue($user->name,"John Locke");
|
||||
$this->assertTrue($user->state() == Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertTrue($user->state() == Doctrine_Entity::STATE_TDIRTY);
|
||||
$user->save();
|
||||
$this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertTrue($user->state() == Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertTrue($user->name,"John Locke");
|
||||
}
|
||||
|
||||
@ -546,10 +546,10 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertTrue(is_numeric($user->id) && $user->id > 0);
|
||||
|
||||
$this->assertTrue($user->getModified() == array());
|
||||
$this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertTrue($user->state() == Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$user->delete();
|
||||
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
@ -570,8 +570,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
$user = $this->connection->getRepository("User")->find(4);
|
||||
$new = $user->copy();
|
||||
|
||||
$this->assertTrue($new instanceof Doctrine_Record);
|
||||
$this->assertTrue($new->state() == Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertTrue($new instanceof Doctrine_Entity);
|
||||
$this->assertTrue($new->state() == Doctrine_Entity::STATE_TDIRTY);
|
||||
|
||||
$new = $user->copy();
|
||||
$new->save();
|
||||
@ -587,8 +587,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
$user = $this->connection->getRepository("User")->find(4);
|
||||
$new = $user->copy();
|
||||
|
||||
$this->assertTrue($new instanceof Doctrine_Record);
|
||||
$this->assertTrue($new->state() == Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertTrue($new instanceof Doctrine_Entity);
|
||||
$this->assertTrue($new->state() == Doctrine_Entity::STATE_TDIRTY);
|
||||
|
||||
$new->loginname = 'jackd';
|
||||
|
||||
@ -702,7 +702,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertTrue($user->Email instanceof Email);
|
||||
$this->assertEqual($user->Email->id, $user->email_id);
|
||||
$this->assertEqual($user->Email->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($user->Email->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($user->Email->address, "drinker@drinkmore.info");
|
||||
$id = $user->Email->id;
|
||||
|
||||
@ -871,7 +871,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
$user = $this->connection->getRepository("User")->find(4);
|
||||
|
||||
$this->assertTrue($user->Email instanceof Doctrine_Record);
|
||||
$this->assertTrue($user->Email instanceof Doctrine_Entity);
|
||||
$this->assertTrue($user->Phonenumber instanceof Doctrine_Collection);
|
||||
$this->assertTrue($user->Group instanceof Doctrine_Collection);
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Doctrine_Relation_Access_TestCase extends Doctrine_UnitTestCase {
|
||||
public function testOneToOneAggregateRelationFetching() {
|
||||
$coll = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner1'");
|
||||
$this->assertTrue(count($coll) == 1);
|
||||
$this->assertTrue($coll[0] instanceof Doctrine_Record);
|
||||
$this->assertTrue($coll[0] instanceof Doctrine_Entity);
|
||||
|
||||
$this->assertEqual($coll[0]->id, 1);
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertTrue($e->Entity[0] instanceof Entity);
|
||||
$this->assertTrue($e->Entity[1] instanceof Entity);
|
||||
|
||||
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
$this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_TCLEAN);
|
||||
|
||||
$e->Entity[0]->name = 'Friend 1';
|
||||
$e->Entity[1]->name = 'Friend 2';
|
||||
@ -69,8 +69,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertEqual($e->Entity[1]->Entity[0]->name, 'Friend 2 1');
|
||||
$this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 2');
|
||||
|
||||
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
$this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_TDIRTY);
|
||||
|
||||
$count = count($this->conn);
|
||||
|
||||
@ -83,7 +83,7 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
|
||||
$this->connection->clear();
|
||||
|
||||
$e = $this->conn->queryOne('FROM Entity e LEFT JOIN e.Entity e2 LEFT JOIN e2.Entity e3 WHERE e.id = 1 ORDER BY e.name, e2.name, e3.name');
|
||||
$this->assertEqual($e->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($e->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$this->assertTrue($e->Entity[0] instanceof Entity);
|
||||
$this->assertTrue($e->Entity[1] instanceof Entity);
|
||||
@ -99,8 +99,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 1');
|
||||
$this->assertEqual($e->Entity[1]->Entity[2]->name, 'Friend 2 2');
|
||||
|
||||
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$this->assertTrue(is_numeric($e->id));
|
||||
|
||||
@ -135,12 +135,12 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertEqual($e->Entity[1]->Entity[0]->name, "Entity test");
|
||||
$this->assertEqual($e->Entity[1]->Entity[1]->name, "Friend 2 1");
|
||||
|
||||
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
$this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$coll = $this->connection->query("FROM Entity WHERE Entity.name = 'Friend 1'");
|
||||
$this->assertEqual($coll->count(), 1);
|
||||
$this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_CLEAN);
|
||||
|
||||
$this->assertEqual($coll[0]->name, "Friend 1");
|
||||
|
||||
|
@ -149,18 +149,18 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
|
||||
public function testCreate()
|
||||
{
|
||||
$record = $this->objTable->create();
|
||||
$this->assertTrue($record instanceof Doctrine_Record);
|
||||
$this->assertTrue($record->state() == Doctrine_Record::STATE_TCLEAN);
|
||||
$this->assertTrue($record instanceof Doctrine_Entity);
|
||||
$this->assertTrue($record->state() == Doctrine_Entity::STATE_TCLEAN);
|
||||
}
|
||||
|
||||
public function testFind()
|
||||
{
|
||||
$record = $this->objTable->find(4);
|
||||
$this->assertTrue($record instanceof Doctrine_Record);
|
||||
$this->assertTrue($record instanceof Doctrine_Entity);
|
||||
|
||||
try {
|
||||
$record = $this->objTable->find('4');
|
||||
$this->assertTrue($record instanceof Doctrine_Record);
|
||||
$this->assertTrue($record instanceof Doctrine_Entity);
|
||||
} catch(Exception $e) {
|
||||
$this->assertTrue(false);
|
||||
}
|
||||
@ -171,7 +171,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
|
||||
$this->assertTrue( ! is_object($record));
|
||||
$this->assertTrue(array_key_exists('id', $record));
|
||||
$this->assertTrue(array_key_exists('name', $record));
|
||||
$this->assertTrue( ! $record instanceof Doctrine_Record);
|
||||
$this->assertTrue( ! $record instanceof Doctrine_Entity);
|
||||
} catch(Exception $e) {
|
||||
$this->assertTrue(false);
|
||||
}
|
||||
@ -221,7 +221,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
|
||||
public function testGetProxy()
|
||||
{
|
||||
$user = $this->objTable->getProxy(4);
|
||||
$this->assertTrue($user instanceof Doctrine_Record);
|
||||
$this->assertTrue($user instanceof Doctrine_Entity);
|
||||
|
||||
try {
|
||||
$record = $this->objTable->find(123);
|
||||
|
@ -107,7 +107,7 @@ class Doctrine_Ticket_438_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
|
||||
|
||||
class T438_Student extends Doctrine_Record
|
||||
class T438_Student extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
@ -119,7 +119,7 @@ class T438_Student extends Doctrine_Record
|
||||
}
|
||||
|
||||
|
||||
class T438_Course extends Doctrine_Record
|
||||
class T438_Course extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
@ -130,7 +130,7 @@ class T438_Course extends Doctrine_Record
|
||||
}
|
||||
}
|
||||
|
||||
class T438_StudentCourse extends Doctrine_Record
|
||||
class T438_StudentCourse extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -31,7 +31,7 @@
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
class stComment extends Doctrine_Record
|
||||
class stComment extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ class Doctrine_Ticket_626B_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
|
||||
|
||||
class T626B_Student extends Doctrine_Record
|
||||
class T626B_Student extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
@ -103,7 +103,7 @@ class T626B_Student extends Doctrine_Record
|
||||
}
|
||||
}
|
||||
|
||||
class T626_Group extends Doctrine_Record
|
||||
class T626_Group extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
@ -117,7 +117,7 @@ class T626_Group extends Doctrine_Record
|
||||
}
|
||||
|
||||
|
||||
class T626_Course extends Doctrine_Record
|
||||
class T626_Course extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
@ -129,7 +129,7 @@ class T626_Course extends Doctrine_Record
|
||||
}
|
||||
}
|
||||
|
||||
class T626B_StudentCourse extends Doctrine_Record
|
||||
class T626B_StudentCourse extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ class Doctrine_Ticket_626C_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
|
||||
|
||||
class T626C_Student1 extends Doctrine_Record
|
||||
class T626C_Student1 extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
@ -73,7 +73,7 @@ class T626C_Student1 extends Doctrine_Record
|
||||
}
|
||||
}
|
||||
|
||||
class T626C_Student2 extends Doctrine_Record
|
||||
class T626C_Student2 extends Doctrine_Entity
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user