This commit is contained in:
parent
0debccfe19
commit
18115c7711
@ -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(),
|
||||
array('type' => Doctrine_Relation::ONE,
|
||||
'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()));
|
||||
$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);
|
||||
|
@ -211,8 +211,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
||||
|
||||
if (isset($this->columns)) {
|
||||
// get the declaring class of setTableDefinition method
|
||||
$method = new ReflectionMethod($this->options['name'], 'setTableDefinition');
|
||||
$class = $method->getDeclaringClass();
|
||||
$method = new ReflectionMethod($this->options['name'], 'setTableDefinition');
|
||||
$class = $method->getDeclaringClass();
|
||||
|
||||
$this->options['declaringClass'] = $class;
|
||||
|
||||
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user