From b3b1f617fe9c34724acb88d336f019c33a05e579 Mon Sep 17 00:00:00 2001 From: zYne Date: Mon, 21 May 2007 21:52:14 +0000 Subject: [PATCH] --- lib/Doctrine/Relation/Parser.php | 34 ++++++++++++++++++++++++----- lib/Doctrine/Relation/ParserOld.php | 4 ++-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/Relation/Parser.php b/lib/Doctrine/Relation/Parser.php index 6fc04adfc..6fb48aed0 100644 --- a/lib/Doctrine/Relation/Parser.php +++ b/lib/Doctrine/Relation/Parser.php @@ -140,18 +140,42 @@ class Doctrine_Relation_Parser 'foreign' => $def['local'])); } if (in_array($def['class'], $localClasses)) { - return new Doctrine_Relation_Association_Self($def); + $rel = new Doctrine_Relation_Association_Self($def); } else { - return new Doctrine_Relation_Association($def); + $rel = new Doctrine_Relation_Association($def); } } else { $def = $this->completeDefinition($def); if ( ! isset($def['foreign'])) { Doctrine::dump($def); } - return new Doctrine_Relation_ForeignKey($def); + $rel = new Doctrine_Relation_ForeignKey($def); + } + if (isset($rel)) { + unset($this->_pending[$name]); + + return $rel; } } + if ($recursive) { + return $this->getRelation($name, false); + } else { + throw new Doctrine_Table_Exception($this->options['name'] . " doesn't have a relation to " . $name); + } + } + /** + * getRelations + * returns an array containing all relation objects + * + * @return array an array of Doctrine_Relation objects + */ + public function getRelations() + { + foreach ($this->_pending as $k => $v) { + $this->getRelation($k); + } + + return $this->_relations; } /** * Completes the given association definition @@ -310,8 +334,8 @@ class Doctrine_Relation_Parser return $def; } } - } - + } Doctrine::dump($this->_table->getComponentName()); + Doctrine::dump($def); throw new Doctrine_Relation_Parser_Exception("Couldn't complete relation definition."); } } diff --git a/lib/Doctrine/Relation/ParserOld.php b/lib/Doctrine/Relation/ParserOld.php index 670cd8d37..983907dec 100644 --- a/lib/Doctrine/Relation/ParserOld.php +++ b/lib/Doctrine/Relation/ParserOld.php @@ -178,8 +178,8 @@ class Doctrine_Relation_ParserOld $lower = strtolower($name); - if (isset($this->columns[$lower])) { - throw new Doctrine_Table_Exception("Couldn't bind relation. Column with name " . $lower . ' already exists!'); + if ($this->_table->hasColumn($lower)) { + throw new Doctrine_Relation_Exception("Couldn't bind relation. Column with name " . $lower . ' already exists!'); } $e = explode(' as ', $name);