Changeset 5016

Show
Ignore:
Timestamp:
10/01/08 19:55:50 (3 months ago)
Author:
romanb
Message:

[1.1] Fixed #1510.

Location:
branches/1.1/lib/Doctrine
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/1.1/lib/Doctrine/Hydrator.php

    r5003 r5016  
    156156            } 
    157157 
    158             $this->_setLastElement($prev, $result, $index, $rootAlias, false); 
     158            $driver->setLastElement($prev, $result, $index, $rootAlias, false); 
    159159            unset($rowData[$rootAlias]); 
    160160 
     
    238238                if ($prev[$parent][$relationAlias] !== null) { 
    239239                    $coll =& $prev[$parent][$relationAlias]; 
    240                     $this->_setLastElement($prev, $coll, $index, $dqlAlias, $oneToOne); 
     240                    $driver->setLastElement($prev, $coll, $index, $dqlAlias, $oneToOne); 
    241241                } 
    242242            } 
     
    249249 
    250250        return $result; 
    251     } 
    252  
    253     /** 
    254      * sets the last element of given data array / collection 
    255      * as previous element 
    256      * 
    257      * @param boolean|integer $index 
    258      * @return void 
    259      * @todo Detailed documentation 
    260      */ 
    261     protected function _setLastElement(&$prev, &$coll, $index, $dqlAlias, $oneToOne) 
    262     { 
    263         if ($coll === self::$_null || $coll === null) { 
    264             unset($prev[$dqlAlias]); // Ticket #1228 
    265             return; 
    266         } 
    267  
    268         if ($index !== false) { 
    269             // Link element at $index to previous element for the component 
    270             // identified by the DQL alias $alias 
    271             $prev[$dqlAlias] =& $coll[$index]; 
    272             return; 
    273         } 
    274  
    275         if (is_array($coll) && $coll) { 
    276             if ($oneToOne) { 
    277                 $prev[$dqlAlias] =& $coll; 
    278             } else { 
    279                 end($coll); 
    280                 $prev[$dqlAlias] =& $coll[key($coll)]; 
    281             } 
    282         } else if (count($coll) > 0) { 
    283             $prev[$dqlAlias] = $coll->getLast(); 
    284         } 
    285251    } 
    286252 
  • branches/1.1/lib/Doctrine/Hydrator/ArrayDriver.php

    r4263 r5016  
    6868        return key($data); 
    6969    } 
     70     
     71    /** 
     72     * sets the last element of given data array / collection 
     73     * as previous element 
     74     * 
     75     * @param boolean|integer $index 
     76     * @return void 
     77     * @todo Detailed documentation 
     78     */ 
     79    public function setLastElement(&$prev, &$coll, $index, $dqlAlias, $oneToOne) 
     80    { 
     81        if ($coll === null) { 
     82            unset($prev[$dqlAlias]); // Ticket #1228 
     83            return; 
     84        } 
     85 
     86        if ($index !== false) { 
     87            // Link element at $index to previous element for the component 
     88            // identified by the DQL alias $alias 
     89            $prev[$dqlAlias] =& $coll[$index]; 
     90            return; 
     91        } 
     92         
     93        if ($coll) { 
     94            if ($oneToOne) { 
     95                $prev[$dqlAlias] =& $coll; 
     96            } else { 
     97                end($coll); 
     98                $prev[$dqlAlias] =& $coll[key($coll)]; 
     99            } 
     100        } 
     101    } 
    70102 
    71103    public function flush() 
  • branches/1.1/lib/Doctrine/Hydrator/RecordDriver.php

    r4341 r5016  
    105105     
    106106    /** 
     107     * sets the last element of given data array / collection 
     108     * as previous element 
     109     * 
     110     * @param boolean|integer $index 
     111     * @return void 
     112     * @todo Detailed documentation 
     113     */ 
     114    public function setLastElement(&$prev, &$coll, $index, $dqlAlias, $oneToOne) 
     115    { 
     116        if ($coll === self::$_null) { 
     117            unset($prev[$dqlAlias]); // Ticket #1228 
     118            return; 
     119        } 
     120 
     121        if ($index !== false) { 
     122            // Link element at $index to previous element for the component 
     123            // identified by the DQL alias $alias 
     124            $prev[$dqlAlias] = $coll[$index]; 
     125            return; 
     126        } 
     127         
     128        if (count($coll) > 0) { 
     129            $prev[$dqlAlias] = $coll->getLast(); 
     130        } 
     131    } 
     132     
     133    /** 
    107134     * Get the classname to return. Most often this is just the options['name'] 
    108135     *