1
0
mirror of synced 2025-01-18 06:21:40 +03:00

method name changes for better custom getter/setter compatibility

Doctrine_Record::getID() -> obtainIdentifier()
Doctrine_Record::setID() -> assignIdentifier()
This commit is contained in:
zYne 2006-09-17 17:59:04 +00:00
parent ddbf6c949b
commit 41ee9173f1
14 changed files with 48 additions and 48 deletions

View File

@ -298,7 +298,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if( ! isset($this->reference)) if( ! isset($this->reference))
return false; return false;
$id = $this->reference->getID(); $id = $this->reference->obtainIdentifier();
if(empty($id)) if(empty($id))
return false; return false;

View File

@ -57,11 +57,11 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
if(empty($this->data)) if(empty($this->data))
return false; return false;
$id = $record->getID(); $id = $record->obtainIdentifier();
$identifier = $this->table->getIdentifier(); $identifier = $this->table->getIdentifier();
foreach($this->data as $key => $v) { foreach($this->data as $key => $v) {
if(is_object($v)) { if(is_object($v)) {
if($v->getID() == $id) if($v->obtainIdentifier() == $id)
break; break;
} elseif(is_array($v[$identifier])) { } elseif(is_array($v[$identifier])) {

View File

@ -576,10 +576,10 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$id = $table->getMaxIdentifier(); $id = $table->getMaxIdentifier();
} }
$record->setID($id); $record->assignIdentifier($id);
$id++; $id++;
} else } else
$record->setID(true); $record->assignIdentifier(true);
// listen the onInsert event // listen the onInsert event
$table->getAttribute(Doctrine::ATTR_LISTENER)->onInsert($record); $table->getAttribute(Doctrine::ATTR_LISTENER)->onInsert($record);
@ -652,7 +652,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$ids = array(); $ids = array();
foreach($deletes as $k => $record) { foreach($deletes as $k => $record) {
$ids[] = $record->getIncremented(); $ids[] = $record->getIncremented();
$record->setID(false); $record->assignIdentifier(false);
} }
if($record instanceof Doctrine_Record) { if($record instanceof Doctrine_Record) {
$table = $record->getTable(); $table = $record->getTable();
@ -794,7 +794,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
} }
$params = array_values($array); $params = array_values($array);
$id = $record->getID(); $id = $record->obtainIdentifier();
if( ! is_array($id)) if( ! is_array($id))
@ -809,7 +809,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$stmt = $this->dbh->prepare($sql); $stmt = $this->dbh->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$record->setID(true); $record->assignIdentifier(true);
return true; return true;
} }

View File

@ -59,7 +59,7 @@ class Doctrine_Lib {
public static function getRecordAsString(Doctrine_Record $record) { public static function getRecordAsString(Doctrine_Record $record) {
$r[] = "<pre>"; $r[] = "<pre>";
$r[] = "Component : ".$record->getTable()->getComponentName(); $r[] = "Component : ".$record->getTable()->getComponentName();
$r[] = "ID : ".$record->getID(); $r[] = "ID : ".$record->obtainIdentifier();
$r[] = "References : ".count($record->getReferences()); $r[] = "References : ".count($record->getReferences());
$r[] = "State : ".Doctrine_Lib::getRecordStateAsString($record->getState()); $r[] = "State : ".Doctrine_Lib::getRecordStateAsString($record->getState());
$r[] = "OID : ".$record->getOID(); $r[] = "OID : ".$record->getOID();
@ -181,7 +181,7 @@ class Doctrine_Lib {
$r[] = get_class($collection); $r[] = get_class($collection);
foreach($collection as $key => $record) { foreach($collection as $key => $record) {
$r[] = "Key : ".$key." ID : ".$record->getID(); $r[] = "Key : ".$key." ID : ".$record->obtainIdentifier();
} }
$r[] = "</pre>"; $r[] = "</pre>";
return implode("\n",$r); return implode("\n",$r);

View File

@ -80,7 +80,7 @@ class Doctrine_Locking_Manager_Pessimistic
public function getLock(Doctrine_Record $record, $userIdent) public function getLock(Doctrine_Record $record, $userIdent)
{ {
$objectType = $record->getTable()->getComponentName(); $objectType = $record->getTable()->getComponentName();
$key = $record->getID(); $key = $record->obtainIdentifier();
$gotLock = false; $gotLock = false;
@ -154,7 +154,7 @@ class Doctrine_Locking_Manager_Pessimistic
public function releaseLock(Doctrine_Record $record, $userIdent) public function releaseLock(Doctrine_Record $record, $userIdent)
{ {
$objectType = $record->getTable()->getComponentName(); $objectType = $record->getTable()->getComponentName();
$key = $record->getID(); $key = $record->obtainIdentifier();
if(is_array($key)) if(is_array($key))
{ {

View File

@ -479,7 +479,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return boolean * @return boolean
*/ */
final public function refresh() { final public function refresh() {
$id = $this->getID(); $id = $this->obtainIdentifier();
if( ! is_array($id)) if( ! is_array($id))
$id = array($id); $id = array($id);
@ -1000,7 +1000,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
switch($fk->getType()): switch($fk->getType()):
case Doctrine_Relation::ONE_COMPOSITE: case Doctrine_Relation::ONE_COMPOSITE:
if(isset($this->originals[$alias]) && $this->originals[$alias]->getID() != $this->references[$alias]->getID()) if(isset($this->originals[$alias]) && $this->originals[$alias]->obtainIdentifier() != $this->references[$alias]->obtainIdentifier())
$this->originals[$alias]->delete(); $this->originals[$alias]->delete();
break; break;
@ -1055,7 +1055,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @param integer $id * @param integer $id
* @return void * @return void
*/ */
final public function setID($id = false) { final public function assignIdentifier($id = false) {
if($id === false) { if($id === false) {
$this->id = array(); $this->id = array();
$this->cleanData(); $this->cleanData();
@ -1078,7 +1078,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* *
* @return array * @return array
*/ */
final public function getID() { final public function obtainIdentifier() {
return $this->id; return $this->id;
} }
/** /**

View File

@ -567,10 +567,10 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
$id = $table->getMaxIdentifier(); $id = $table->getMaxIdentifier();
} }
$record->setID($id); $record->assignIdentifier($id);
$id++; $id++;
} else } else
$record->setID(true); $record->assignIdentifier(true);
// listen the onInsert event // listen the onInsert event
$table->getAttribute(Doctrine::ATTR_LISTENER)->onInsert($record); $table->getAttribute(Doctrine::ATTR_LISTENER)->onInsert($record);
@ -643,7 +643,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
$ids = array(); $ids = array();
foreach($deletes as $k => $record) { foreach($deletes as $k => $record) {
$ids[] = $record->getIncremented(); $ids[] = $record->getIncremented();
$record->setID(false); $record->assignIdentifier(false);
} }
if($record instanceof Doctrine_Record) { if($record instanceof Doctrine_Record) {
$table = $record->getTable(); $table = $record->getTable();
@ -785,7 +785,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
} }
$params = array_values($array); $params = array_values($array);
$id = $record->getID(); $id = $record->obtainIdentifier();
if( ! is_array($id)) if( ! is_array($id))
@ -800,7 +800,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
$stmt = $this->dbh->prepare($sql); $stmt = $this->dbh->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$record->setID(true); $record->assignIdentifier(true);
return true; return true;
} }

View File

@ -39,7 +39,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user->save(); $user->save();
$user = $this->connection->getTable("User")->find($user->getID()); $user = $this->connection->getTable("User")->find($user->obtainIdentifier());
$this->assertEqual($user->name,"Jack"); $this->assertEqual($user->name,"Jack");
$user["name"] = "Jack"; $user["name"] = "Jack";
@ -57,7 +57,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user->save(); $user->save();
$user = $this->connection->getTable("User")->find($user->getID()); $user = $this->connection->getTable("User")->find($user->obtainIdentifier());
$this->assertEqual($user->name,"Jack"); $this->assertEqual($user->name,"Jack");
$user->name = "Jack"; $user->name = "Jack";
@ -74,7 +74,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user->save(); $user->save();
$user = $this->connection->getTable("User")->find($user->getID()); $user = $this->connection->getTable("User")->find($user->obtainIdentifier());
$this->assertEqual($user->get("name"),"Jack"); $this->assertEqual($user->get("name"),"Jack");

View File

@ -40,12 +40,12 @@ class Doctrine_BatchIteratorTestCase extends Doctrine_UnitTestCase {
$user->save(); $user->save();
$user = $user->getTable()->find($user->getID()); $user = $user->getTable()->find($user->obtainIdentifier());
$this->assertEqual($user->name, "tester"); $this->assertEqual($user->name, "tester");
$this->assertEqual($user->Address[0]->address, "street 1"); $this->assertEqual($user->Address[0]->address, "street 1");
$this->assertEqual($user->Address[1]->address, "street 2"); $this->assertEqual($user->Address[1]->address, "street 2");
$user = $user->getTable()->find($user->getID()); $user = $user->getTable()->find($user->obtainIdentifier());
$a = array(); $a = array();
foreach($user->Address as $address) { foreach($user->Address as $address) {
$a[] = $address->address; $a[] = $address->address;

View File

@ -12,7 +12,7 @@ class Doctrine_Cache_FileTestCase extends Doctrine_UnitTestCase {
$record = $this->cache->fetch(4); $record = $this->cache->fetch(4);
$this->assertTrue($record instanceof Doctrine_Record); $this->assertTrue($record instanceof Doctrine_Record);
$this->assertTrue($record->getID() == $this->old->getID()); $this->assertTrue($record->obtainIdentifier() == $this->old->obtainIdentifier());
$this->assertTrue($this->cache->getTable() == $this->objTable); $this->assertTrue($this->cache->getTable() == $this->objTable);
} }

View File

@ -26,7 +26,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
foreach($this->old as $name => $value) { foreach($this->old as $name => $value) {
$this->assertEqual($record->get($name), $value); $this->assertEqual($record->get($name), $value);
} }
$this->assertEqual($record->getID(), $this->old->getID()); $this->assertEqual($record->obtainIdentifier(), $this->old->obtainIdentifier());
} }
public function testFetchMultiple() { public function testFetchMultiple() {

View File

@ -109,7 +109,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
$u1->name = "Jean Reno"; $u1->name = "Jean Reno";
$u1->save(); $u1->save();
$id = $u1->getID(); $id = $u1->obtainIdentifier();
$u1->delete(); $u1->delete();
} }

View File

@ -12,15 +12,15 @@ class Doctrine_CustomPrimaryKeyTestCase extends Doctrine_UnitTestCase {
$this->assertTrue($c instanceof Doctrine_Record); $this->assertTrue($c instanceof Doctrine_Record);
$c->name = "custom pk test"; $c->name = "custom pk test";
$this->assertEqual($c->getID(), array()); $this->assertEqual($c->obtainIdentifier(), array());
$c->save(); $c->save();
$this->assertEqual($c->getID(), array("uid" => 1)); $this->assertEqual($c->obtainIdentifier(), array("uid" => 1));
$this->connection->clear(); $this->connection->clear();
$c = $this->connection->getTable('CustomPK')->find(1); $c = $this->connection->getTable('CustomPK')->find(1);
$this->assertEqual($c->getID(), array("uid" => 1)); $this->assertEqual($c->obtainIdentifier(), array("uid" => 1));
} }
} }
?> ?>

View File

@ -290,7 +290,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$user2 = unserialize($str); $user2 = unserialize($str);
$this->assertTrue($user2 instanceof User); $this->assertTrue($user2 instanceof User);
$this->assertEqual($user2->getID(),$user->getID()); $this->assertEqual($user2->obtainIdentifier(),$user->obtainIdentifier());
} }
public function testCallback() { public function testCallback() {
@ -308,7 +308,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$record = new EntityReference(); $record = new EntityReference();
$this->assertEqual($record->getTable()->getIdentifier(), array("entity1","entity2")); $this->assertEqual($record->getTable()->getIdentifier(), array("entity1","entity2"));
$this->assertEqual($record->getTable()->getIdentifierType(), Doctrine_Identifier::COMPOSITE); $this->assertEqual($record->getTable()->getIdentifierType(), Doctrine_Identifier::COMPOSITE);
$this->assertEqual($record->getID(), array("entity1" => null, "entity2" => null)); $this->assertEqual($record->obtainIdentifier(), array("entity1" => null, "entity2" => null));
$this->assertEqual($record->getState(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($record->getState(), Doctrine_Record::STATE_TCLEAN);
$record->entity1 = 3; $record->entity1 = 3;
@ -316,45 +316,45 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity2, 4);
$this->assertEqual($record->entity1, 3); $this->assertEqual($record->entity1, 3);
$this->assertEqual($record->getState(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($record->getState(), Doctrine_Record::STATE_TDIRTY);
$this->assertEqual($record->getID(), array("entity1" => null, "entity2" => null)); $this->assertEqual($record->obtainIdentifier(), array("entity1" => null, "entity2" => null));
$record->save(); $record->save();
$this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity2, 4);
$this->assertEqual($record->entity1, 3); $this->assertEqual($record->entity1, 3);
$this->assertEqual($record->getID(), array("entity1" => 3, "entity2" => 4)); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 3, "entity2" => 4));
$record = $record->getTable()->find($record->getID()); $record = $record->getTable()->find($record->obtainIdentifier());
$this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity2, 4);
$this->assertEqual($record->entity1, 3); $this->assertEqual($record->entity1, 3);
$this->assertEqual($record->getID(), array("entity1" => 3, "entity2" => 4)); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 3, "entity2" => 4));
$record->entity2 = 5; $record->entity2 = 5;
$record->entity1 = 2; $record->entity1 = 2;
$this->assertEqual($record->getState(), Doctrine_Record::STATE_DIRTY); $this->assertEqual($record->getState(), Doctrine_Record::STATE_DIRTY);
$this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity2, 5);
$this->assertEqual($record->entity1, 2); $this->assertEqual($record->entity1, 2);
$this->assertEqual($record->getID(), array("entity1" => 3, "entity2" => 4)); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 3, "entity2" => 4));
$record->save(); $record->save();
$this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity2, 5);
$this->assertEqual($record->entity1, 2); $this->assertEqual($record->entity1, 2);
$this->assertEqual($record->getID(), array("entity1" => 2, "entity2" => 5)); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 2, "entity2" => 5));
$record = $record->getTable()->find($record->getID()); $record = $record->getTable()->find($record->obtainIdentifier());
$this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity2, 5);
$this->assertEqual($record->entity1, 2); $this->assertEqual($record->entity1, 2);
$this->assertEqual($record->getID(), array("entity1" => 2, "entity2" => 5)); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 2, "entity2" => 5));
$record->refresh(); $record->refresh();
$this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity2, 5);
$this->assertEqual($record->entity1, 2); $this->assertEqual($record->entity1, 2);
$this->assertEqual($record->getID(), array("entity1" => 2, "entity2" => 5)); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 2, "entity2" => 5));
$record = new EntityReference(); $record = new EntityReference();
$record->entity2 = 6; $record->entity2 = 6;
@ -405,7 +405,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->connection->flush(); $this->connection->flush();
$task = $task->getTable()->find($task->getID()); $task = $task->getTable()->find($task->obtainIdentifier());
$this->assertEqual($task->name, "Task 1"); $this->assertEqual($task->name, "Task 1");
$this->assertEqual($task->ResourceAlias[0]->name, "Resource 1"); $this->assertEqual($task->ResourceAlias[0]->name, "Resource 1");
@ -475,7 +475,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($user->created, null); $this->assertEqual($user->created, null);
$this->assertEqual($user->updated, null); $this->assertEqual($user->updated, null);
$user->save(); $user->save();
$id = $user->getID(); $id = $user->obtainIdentifier();
$user = $user->getTable()->find($id); $user = $user->getTable()->find($id);
$this->assertEqual($user->name, "Jack Daniels"); $this->assertEqual($user->name, "Jack Daniels");
$this->assertEqual($user->created, null); $this->assertEqual($user->created, null);
@ -539,7 +539,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($c->name, "child 1"); $this->assertEqual($c->name, "child 1");
$this->assertEqual($e->Child[0]->parent_id, 1); $this->assertEqual($e->Child[0]->parent_id, 1);
$this->assertEqual($e->Child[0]->Parent->getID(), $e->getID()); $this->assertEqual($e->Child[0]->Parent->obtainIdentifier(), $e->obtainIdentifier());
$this->assertEqual($e->Child[1]->parent_id, 1); $this->assertEqual($e->Child[1]->parent_id, 1);
@ -865,8 +865,8 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$user->save(); $user->save();
$this->assertEqual($user->Group->count(), 1); $this->assertEqual($user->Group->count(), 1);
$this->assertEqual($user->Group[0]->getID(), $record2->getID()); $this->assertEqual($user->Group[0]->obtainIdentifier(), $record2->obtainIdentifier());
$this->assertFalse($user->Group[0]->getID() == $record->getID()); $this->assertFalse($user->Group[0]->obtainIdentifier() == $record->obtainIdentifier());
$user->Group[0] = $record; $user->Group[0] = $record;