1
0
mirror of synced 2025-01-19 06:51:40 +03:00
This commit is contained in:
zYne 2007-07-13 16:22:49 +00:00
parent 0debccfe19
commit 18115c7711
2 changed files with 26 additions and 13 deletions

View File

@ -74,6 +74,15 @@ class Doctrine_Relation_Parser
return $this->_pending[$name]; return $this->_pending[$name];
} }
public function hasRelation($name)
{
if ( ! isset($this->_pending[$name]) && ! isset($this->_relations[$name])) {
return false;
}
return true;
}
/** /**
* binds a relation * binds a relation
* *
@ -190,17 +199,21 @@ class Doctrine_Relation_Parser
if ( ! isset($this->_pending[$def['refClass']]) && if ( ! isset($this->_pending[$def['refClass']]) &&
! isset($this->_relations[$def['refClass']])) { ! isset($this->_relations[$def['refClass']])) {
$def['refTable']->getRelationParser()->bind($this->_table->getComponentName(), $parser = $def['refTable']->getRelationParser();
array('type' => Doctrine_Relation::ONE, if ( ! $parser->hasRelation($this->_table->getComponentName())) {
'local' => $def['local'], $parser->bind($this->_table->getComponentName(),
'foreign' => $this->_table->getIdentifier(), array('type' => Doctrine_Relation::ONE,
'localKey' => true, 'local' => $def['local'],
)); 'foreign' => $this->_table->getIdentifier(),
'localKey' => true,
$this->bind($def['refClass'], array('type' => Doctrine_Relation::MANY, ));
'foreign' => $def['local'], }
'local' => $this->_table->getIdentifier()));
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)) { if (in_array($def['class'], $localClasses)) {
$rel = new Doctrine_Relation_Nest($def); $rel = new Doctrine_Relation_Nest($def);

View File

@ -211,8 +211,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if (isset($this->columns)) { if (isset($this->columns)) {
// get the declaring class of setTableDefinition method // get the declaring class of setTableDefinition method
$method = new ReflectionMethod($this->options['name'], 'setTableDefinition'); $method = new ReflectionMethod($this->options['name'], 'setTableDefinition');
$class = $method->getDeclaringClass(); $class = $method->getDeclaringClass();
$this->options['declaringClass'] = $class; $this->options['declaringClass'] = $class;
@ -364,7 +364,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if ($relation instanceof Doctrine_Relation_LocalKey) { if ($relation instanceof Doctrine_Relation_LocalKey) {
$def = array('local' => $relation->getLocal(), $def = array('local' => $relation->getLocal(),
'foreign' => $this->getIdentifier(), 'foreign' => $relation->getForeign(),
'foreignTable' => $relation->getTable()->getTableName()); 'foreignTable' => $relation->getTable()->getTableName());
if (($key = array_search($def, $options['foreignKeys'])) === false) { if (($key = array_search($def, $options['foreignKeys'])) === false) {