Changeset 4785 for trunk/lib

Show
Ignore:
Timestamp:
08/21/08 21:45:19 (5 months ago)
Author:
guilhermeblanco
Message:

DQL Parser refactorings and enhancements. Finished basic drat of Join support.

Location:
trunk/lib/Doctrine
Files:
1 added
30 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/Doctrine/Entity.php

    r4776 r4785  
    2424/** 
    2525 * Base class for all Entities (objects with persistent state in a RDBMS that are 
    26  * managed by Doctrine). Kind of a Layer Suptertype. 
     26 * managed by Doctrine). Kind of a Layer Supertype. 
    2727 *  
    2828 * NOTE: Methods that are intended for internal use only but must be public 
     
    127127     * The values that make up the ID/primary key of the entity. 
    128128     * 
    129      * @var array                    
     129     * @var array 
    130130     */ 
    131131    private $_id = array(); 
     
    134134     * The entity data. 
    135135     * 
    136      * @var array                   
     136     * @var array 
    137137     */ 
    138138    private $_data = array(); 
     
    174174     */ 
    175175    private $_references = array(); 
    176      
     176 
    177177    /** 
    178178     * The EntityManager that is responsible for the persistent state of the entity. 
     
    186186     * during script execution. 
    187187     *  
    188      * @var integer                   
     188     * @var integer 
    189189     */ 
    190190    private $_oid; 
    191      
     191 
    192192    /** 
    193193     * Flag that indicates whether the entity is dirty. 
     
    215215            $this->_state = self::STATE_NEW; 
    216216        } 
    217          
     217 
    218218        // @todo read from attribute the first time and move this initialization elsewhere. 
    219219        self::$_useAutoAccessorOverride = true;  
    220220    } 
    221      
     221 
    222222    /** 
    223223     * Returns the object identifier. 
     
    296296            } 
    297297        } 
    298          
     298 
    299299        $str = serialize($vars); 
    300300 
     
    331331            $this->$k = $v; 
    332332        } 
    333          
     333 
    334334        $this->_class = $this->_em->getClassMetadata($this->_entityName); 
    335335 
     
    351351 
    352352        $this->_extractIdentifier(!$this->isNew()); 
    353          
     353 
    354354        //$this->postUnserialize($event); 
    355355    } 
     
    376376     * Gets the current field values. 
    377377     * 
    378      * @return array  The fields and their values.                      
     378     * @return array  The fields and their values. 
    379379     */ 
    380380    final public function getData() 
     
    391391     */ 
    392392    final protected function _get($fieldName) 
    393     {     
     393    { 
    394394        $nullObj = Doctrine_Null::$INSTANCE; 
    395395        if (isset($this->_data[$fieldName])) { 
     
    416416        } 
    417417    } 
    418      
     418 
    419419    /** 
    420420     * Sets the value of a field (regular field or reference). 
     
    456456        } 
    457457    } 
    458      
     458 
    459459    private function _registerDirty() 
    460460    { 
     
    464464        } 
    465465    } 
    466      
     466 
    467467    /** 
    468468     * INTERNAL: 
     
    483483        return $this->_data[$fieldName]; 
    484484    } 
    485      
     485 
    486486    /** 
    487487     * INTERNAL: 
     
    499499        $this->_data[$fieldName] = $value; 
    500500    } 
    501      
     501 
    502502    /** 
    503503     * INTERNAL: 
     
    516516        return $this->_references[$fieldName]; 
    517517    } 
    518      
     518 
    519519    /** 
    520520     * INTERNAL: 
     
    533533            return; 
    534534        } 
    535          
     535 
    536536        $rel = $this->_class->getRelation($name); 
    537537 
     
    576576        $this->_references[$name] = $value; 
    577577    } 
    578      
     578 
    579579    /** 
    580580     * INTERNAL: 
     
    593593            return; 
    594594        } 
    595          
     595 
    596596        $rel = $this->_class->getAssociationMapping($name); 
    597597 
     
    642642        return $this->_get($fieldName); 
    643643    } 
    644      
     644 
    645645    /** 
    646646     * Gets the custom mutator method for a field, if it exists. 
     
    661661                } 
    662662            } 
    663              
     663 
    664664            if ($setter = $this->_class->getCustomMutator($fieldName)) { 
    665665                self::$_mutatorCache[$this->_entityName][$fieldName] = $setter; 
     
    668668            } 
    669669        } 
    670          
     670 
    671671        return self::$_mutatorCache[$this->_entityName][$fieldName]; 
    672672    } 
    673      
     673 
    674674    /** 
    675675     * Gets the custom accessor method of a field, if it exists. 
     
    696696            } 
    697697        } 
    698          
     698 
    699699        return self::$_accessorCache[$this->_entityName][$fieldName]; 
    700700    } 
    701      
     701 
    702702    /** 
    703703     * Gets the entity class name. 
     
    774774        } 
    775775    } 
    776      
     776 
    777777    /** 
    778778     * INTERNAL: 
     
    785785        return $this->_dataChangeSet; 
    786786    } 
    787      
     787 
    788788    final public function _getReferenceChangeSet() 
    789789    { 
    790790        return $this->_referenceChangeSet; 
    791791    } 
    792      
     792 
    793793    /** 
    794794     * Checks whether the entity already has a persistent state. 
     
    894894        $this->_references[$alias] = $coll; 
    895895    } 
    896      
     896 
    897897    /** 
    898898     * Gets the ClassMetadata object that describes the entity class. 
     
    904904        return $this->_class; 
    905905    } 
    906      
     906 
    907907    /** 
    908908     * Gets the EntityManager that is responsible for the persistence of  
     
    915915        return $this->_em; 
    916916    } 
    917      
     917 
    918918    /** 
    919919     * Gets the EntityRepository of the Entity. 
     
    925925        return $this->_em->getRepository($this->_entityName); 
    926926    } 
    927      
     927 
    928928    /** 
    929929     * @todo Why toString() and __toString() ? 
     
    942942        return (string)$this->_oid; 
    943943    } 
    944      
     944 
    945945    /** 
    946946     * Helps freeing the memory occupied by the entity. 
     
    970970        } 
    971971    } 
    972      
     972 
    973973    /** 
    974974     * Check if an offsetExists. 
     
    10231023        return $this->remove($offset); 
    10241024    } 
    1025      
     1025 
    10261026    /** 
    10271027     * __set 
  • trunk/lib/Doctrine/Query/AbstractResult.php

    r4451 r4785  
    124124    public function getQueryComponent($componentAlias) 
    125125    { 
    126         if ( ! isset($this->_queryComponents[$componentAlias])) { 
     126        if ( ! array_key_exists($componentAlias, $this->_queryComponents)) { 
    127127            throw new Doctrine_Query_Exception('Unknown query component ' . $componentAlias); 
    128128        } 
  • trunk/lib/Doctrine/Query/Parser.php

    r4725 r4785  
    174174 
    175175    /** 
    176      * @todo [TODO] Document these! 
     176     * Moves the parser scanner to next token 
     177     * 
     178     * @return void 
    177179     */ 
    178180    public function next() 
  • trunk/lib/Doctrine/Query/Production/BetweenExpression.php

    r4523 r4785  
    6666             . $this->_fromExpression->buildSql() . ' AND ' . $this->_toExpression->buildSql(); 
    6767    } 
    68      
    69     /** 
    70      * Visitor support. 
    71      * 
    72      * @param object $visitor 
    73      */ 
    74     public function accept($visitor) 
    75     { 
    76         $this->_fromExpression->accept($visitor); 
    77         $this->_toExpression->accept($visitor); 
    78         $visitor->visitBetweenExpression($this); 
    79     } 
    80      
     68 
     69 
    8170    /* Getters */ 
    82      
    8371    public function isNot() 
    8472    { 
    8573        return $this->_not; 
    8674    } 
    87      
     75 
     76 
    8877    public function getFromExpression() 
    8978    { 
    9079        return $this->_fromExpression; 
    9180    } 
    92      
     81 
     82 
    9383    public function getToExpression() 
    9484    { 
  • trunk/lib/Doctrine/Query/Production/ComparisonExpression.php

    r4523 r4785  
    2525 * @package     Doctrine 
    2626 * @subpackage  Query 
     27 * @author      Guilherme Blanco <guilhermeblanco@hotmail.com> 
    2728 * @author      Janne Vanhala <jpvanhal@cc.hut.fi> 
    2829 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL 
     
    7273        ); 
    7374    } 
    74      
    75     /** 
    76      * Visitor support. 
    77      * 
    78      * @param object $visitor 
    79      */ 
    80     public function accept($visitor) 
    81     { 
    82         $this->_expression->accept($visitor); 
    83         $visitor->visitComparisonExpression($this); 
    84     } 
    85      
     75 
     76 
    8677    /* Getters */ 
    87      
    8878    public function getOperator() 
    8979    { 
    9080        return $this->_operator; 
    9181    } 
    92      
     82 
     83 
    9384    public function getExpression() 
    9485    { 
    9586        return $this->_expression; 
    9687    } 
    97      
     88 
     89 
    9890    public function isSubselect() 
    9991    { 
  • trunk/lib/Doctrine/Query/Production/ComparisonOperator.php

    r4523 r4785  
    2525 * @package     Doctrine 
    2626 * @subpackage  Query 
     27 * @author      Guilherme Blanco <guilhermeblanco@hotmail.com> 
    2728 * @author      Janne Vanhala <jpvanhal@cc.hut.fi> 
    2829 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL 
     
    7980        } 
    8081    } 
    81      
    82     /** 
    83      * Visitor support. 
    84      * 
    85      * @param object $visitor 
    86      */ 
    87     public function accept($visitor) 
    88     { 
    89         $visitor->visitComparisonOperator($this); 
    90     } 
    9182} 
  • trunk/lib/Doctrine/Query/Production/ConditionalExpression.php

    r4523 r4785  
    7070        return $value->buildSql(); 
    7171    } 
    72      
    73     /** 
    74      * Visitor support. 
    75      * 
    76      * @param object $visitor 
    77      */ 
    78     public function accept($visitor) 
    79     { 
    80         foreach ($this->_conditionalTerms as $term) { 
    81             $term->accept($visitor); 
    82         } 
    83         $visitor->visitConditionalExpression($this); 
    84     } 
    85      
     72 
     73 
    8674    /* Getters */ 
    87      
    8875    public function getConditionalTerms() 
    8976    { 
  • trunk/lib/Doctrine/Query/Production/ConditionalFactor.php

    r4523 r4785  
    6161        return 'NOT ' . $this->_conditionalPrimary->buildSql(); 
    6262    } 
    63      
    64     /** 
    65      * Visitor support 
    66      * 
    67      * @param object $visitor 
    68      */ 
    69     public function accept($visitor) 
    70     { 
    71         $this->_conditionalPrimary->accept($visitor); 
    72         $visitor->visitConditionalFactor($this); 
    73     } 
    74      
     63 
     64 
    7565    /* Getters */ 
    76      
    7766    public function getConditionalPrimary() 
    7867    { 
  • trunk/lib/Doctrine/Query/Production/ConditionalPrimary.php

    r4523 r4785  
    9999        return false; 
    100100    } 
    101      
    102     public function accept($visitor) 
     101 
     102 
     103    /* Getters */ 
     104    public function getConditionalExpression() 
    103105    { 
    104         $this->_conditionalExpression->accept($visitor); 
    105         $visitor->visitConditionalPrimary($this); 
     106        return $this->_conditionalExpression; 
    106107    } 
    107108} 
  • trunk/lib/Doctrine/Query/Production/ConditionalTerm.php

    r4523 r4785  
    7070        return $value->buildSql(); 
    7171    } 
    72      
    73     /** 
    74      * Visitor support 
    75      * 
    76      * @param object $visitor 
    77      */ 
    78     public function accept($visitor) 
    79     { 
    80         foreach ($this->_conditionalFactors as $factor) { 
    81             $factor->accept($visitor); 
    82         } 
    83         $visitor->visitConditionalTerm($this); 
    84     } 
    85      
     72 
     73 
    8674    /* Getters */ 
    87      
    8875    public function getConditionalFactors() 
    8976    { 
  • trunk/lib/Doctrine/Query/Production/ExistsExpression.php

    r4523 r4785  
    5252        return 'EXISTS (' . $this->_subselect->buildSql() . ')'; 
    5353    } 
    54      
    55     /** 
    56      * Visitor support 
    57      * 
    58      * @param object $visitor 
    59      */ 
    60     public function accept($visitor) 
    61     { 
    62         $this->_subselect->accept($visitor); 
    63         $visitor->visitExistsExpression($this); 
    64     } 
    65      
     54 
     55 
    6656    /* Getters */ 
    67      
    6857    public function getSubselect() 
    6958    { 
  • trunk/lib/Doctrine/Query/Production/Expression.php

    r4523 r4785  
    8787        return (is_string($value) ? $value : $value->buildSql()); 
    8888    } 
    89      
    90     /** 
    91      * Visitor support 
    92      * 
    93      * @param object $visitor 
    94      */ 
    95     public function accept($visitor) 
    96     { 
    97         foreach ($this->_terms as $term) { 
    98             $term->accept($visitor); 
    99         } 
    100         $visitor->visitExpression($this); 
    101     } 
    102      
     89 
     90 
    10391    /* Getters */ 
    104      
    10592    public function getTerms() 
    10693    { 
  • trunk/lib/Doctrine/Query/Production/FieldIdentificationVariable.php

    r4523 r4785  
    2525 * @package     Doctrine 
    2626 * @subpackage  Query 
     27 * @author      Guilherme Blanco <guilhermeblanco@hotmail.com> 
    2728 * @author      Janne Vanhala <jpvanhal@cc.hut.fi> 
    2829 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL 
     
    7576                            . Doctrine_Query_Production::SQLALIAS_SEPARATOR . $idx; 
    7677    } 
    77      
    78     /** 
    79      * Visitor support 
    80      * 
    81      * @param object $visitor 
    82      */ 
    83     public function accept($visitor) 
    84     { 
    85         $visitor->visitFieldIdentificationVariable($this); 
    86     } 
    87      
     78 
     79 
    8880    /* Getters */ 
    89      
    9081    public function getFieldAlias() 
    9182    { 
    9283        return $this->_fieldAlias; 
    9384    } 
    94      
     85 
     86 
    9587    public function getColumnAlias() 
    9688    { 
  • trunk/lib/Doctrine/Query/Production/FromClause.php

    r4523 r4785  
    7272        return $value->buildSql(); 
    7373    } 
    74      
    75     /**</