Commit 18115c77 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 0debccfe
......@@ -74,6 +74,15 @@ class Doctrine_Relation_Parser
return $this->_pending[$name];
}
public function hasRelation($name)
{
if ( ! isset($this->_pending[$name]) && ! isset($this->_relations[$name])) {
return false;
}
return true;
}
/**
* binds a relation
*
......@@ -190,17 +199,21 @@ class Doctrine_Relation_Parser
if ( ! isset($this->_pending[$def['refClass']]) &&
! isset($this->_relations[$def['refClass']])) {
$def['refTable']->getRelationParser()->bind($this->_table->getComponentName(),
$parser = $def['refTable']->getRelationParser();
if ( ! $parser->hasRelation($this->_table->getComponentName())) {
$parser->bind($this->_table->getComponentName(),
array('type' => Doctrine_Relation::ONE,
'local' => $def['local'],
'foreign' => $this->_table->getIdentifier(),
'localKey' => true,
));
}
if ( ! $this->hasRelation($def['refClass'])) {
$this->bind($def['refClass'], array('type' => Doctrine_Relation::MANY,
'foreign' => $def['local'],
'local' => $this->_table->getIdentifier()));
}
}
if (in_array($def['class'], $localClasses)) {
$rel = new Doctrine_Relation_Nest($def);
......
......@@ -364,7 +364,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if ($relation instanceof Doctrine_Relation_LocalKey) {
$def = array('local' => $relation->getLocal(),
'foreign' => $this->getIdentifier(),
'foreign' => $relation->getForeign(),
'foreignTable' => $relation->getTable()->getTableName());
if (($key = array_search($def, $options['foreignKeys'])) === false) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment