From ddf0ceab8285a2a5a07f41e9f9e86e0a7f0524eb Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 27 Sep 2006 21:41:20 +0000 Subject: [PATCH] Doctrine_Collection::internalAdd() removed, fixes #129 Ticket: 129 --- lib/Doctrine/Collection.php | 32 -------------------------------- lib/Doctrine/Record.php | 4 ++-- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index 22a13757e..e638ffa68 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -487,38 +487,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator $this->data[$key] = $record; } - /** - * adds a record to collection - * @param Doctrine_Record $record record to be added - * @param string $key optional key for the record - * @return boolean - */ - public function internalAdd(Doctrine_Record $record,$key = null) { - if(in_array($record,$this->data)) - return false; - - if(isset($this->reference_field)) - $record->set($this->reference_field, $this->reference, false); - - if(isset($key)) { - if(isset($this->data[$key])) - return false; - - $this->data[$key] = $record; - return true; - } - - if(isset($this->keyColumn)) { - $value = $record->get($this->keyColumn); - if($value === null) - throw new Doctrine_Collection_Exception("Couldn't create collection index. Record field '".$this->keyColumn."' was null."); - - $this->data[$value] = $record; - } else - $this->data[] = $record; - - return true; - } /** * adds a record to collection * @param Doctrine_Record $record record to be added diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 95332e612..feac54df1 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -1188,8 +1188,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite public function addReference(Doctrine_Record $record, Doctrine_Relation $connector, $key = null) { $alias = $connector->getAlias(); - $this->references[$alias]->internalAdd($record, $key); - $this->originals[$alias]->internalAdd($record, $key); + $this->references[$alias]->add($record, $key); + $this->originals[$alias]->add($record, $key); } /** * getReferences