Changeset 4472

Show
Ignore:
Timestamp:
06/06/08 16:30:01 (13 months ago)
Author:
jwage
Message:

fixes #1044 again - Added override option for relationship options to override the relation if it already exists

Location:
branches/0.11
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Import/Schema.php

    r4367 r4472  
    116116                                                          'onDelete', 
    117117                                                          'onUpdate', 
    118                                                           'equal'), 
     118                                                          'equal', 
     119                                                          'override'), 
    119120 
    120121                                   'inheritance'=>  array('type', 
  • branches/0.11/lib/Doctrine/Relation.php

    r4319 r4472  
    7979                                  'equal'       => false, 
    8080                                  'cascade'     => array(), // application-level cascades 
    81                                   'owningSide'  => false // whether this is the owning side 
     81                                  'owningSide'  => false, // whether this is the owning side 
     82                                  'override'    => false // whether to override if relation exists already 
    8283                                  ); 
    8384 
  • branches/0.11/lib/Doctrine/Relation/Parser.php

    r4387 r4472  
    136136        } 
    137137 
    138         if ($this->hasRelation($alias)) { 
     138        if ($this->hasRelation($alias) && (! isset($options['override']) || ! $options['override'])) { 
    139139            throw new Doctrine_Relation_Exception('A relationship with the name "' . $alias . '" already exists.'); 
    140140        } 
     141 
     142        if (isset($this->relations[$alias])) {  
     143                    unset($this->relations[$alias]);  
     144        } 
     145 
     146        if (isset($this->_pending[$alias])) {  
     147                    unset($this->_pending[$alias]);  
     148        }  
    141149 
    142150        $this->_pending[$alias] = array_merge($options, array('class' => $name, 'alias' => $alias)); 
  • branches/0.11/manual/docs/en/relations.txt

    r4319 r4472  
    1414* **onDelete**, (optional) the onDelete integrity action that is applied on the foreign key constraint when the tables are created by Doctrine. 
    1515* **onUpdate**, (optional) the onUpdate integrity action that is applied on the foreign key constraint when the tables are created by Doctrine. 
     16* **override**, (optional) the override option will override the relation definition if one already exists with the same name. This is useful in cases where you have child classes using inheritance which redefine a relations information for the child class. 
    1617 
    1718So lets take our first example, say we have two classes Forum_Board and Forum_Thread. Here Forum_Board has many  
  • branches/0.11/tests/run.php

    r4460 r4472  
    7373$tickets->addTestCase(new Doctrine_Ticket_1028_TestCase()); 
    7474$tickets->addTestCase(new Doctrine_Ticket_1071_TestCase()); 
     75$tickets->addTestCase(new Doctrine_Ticket_1044_TestCase()); 
    7576$test->addTestCase($tickets); 
    7677