Changeset 4496

Show
Ignore:
Timestamp:
06/08/08 20:55:26 (13 months ago)
Author:
jwage
Message:

fixes #1121

Location:
branches/0.11/lib
Files:
5 modified

Legend:

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

    r4446 r4496  
    196196    const ATTR_RECURSIVE_MERGE_FIXTURES = 162; 
    197197    const ATTR_SINGULARIZE_IMPORT       = 163; 
     198    const ATTR_USE_DQL_CALLBACKS        = 164; 
    198199 
    199200    /** 
  • branches/0.11/lib/Doctrine/Configurable.php

    r4317 r4496  
    182182            case Doctrine::ATTR_RECURSIVE_MERGE_FIXTURES; 
    183183            case Doctrine::ATTR_SINGULARIZE_IMPORT; 
     184            case Doctrine::ATTR_USE_DQL_CALLBACKS; 
    184185 
    185186                break; 
  • branches/0.11/lib/Doctrine/Manager.php

    r4363 r4496  
    102102                        Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE  => 'doctrine', 
    103103                        Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES   => false, 
     104                        Doctrine::ATTR_USE_DQL_CALLBACKS        => false, 
    104105                        );  
    105106            foreach ($attributes as $attribute => $value) { 
  • branches/0.11/lib/Doctrine/Query/Abstract.php

    r4491 r4496  
    10791079        $this->_preQueried = true; 
    10801080 
    1081         $callback = $this->_getDqlCallback(); 
    1082  
    1083         // if there is no callback for the query type, then we can return early 
    1084         if ( ! $callback) { 
    1085             return; 
    1086         } 
    1087  
    1088         // parse the FROM clause to find all models used in the DQL 
    1089         $from = new Doctrine_Query_From($this); 
    1090         $this->_components = array(); 
    1091         foreach ($this->_dqlParts['from'] as $key => $table) { 
    1092             $componentClause = $from->parse($table, true); 
    1093             foreach ($componentClause as $c) { 
    1094                 // remove the prefix if there is one (aka "f.Bar" => "Bar") 
    1095                 $component = explode('.', $c[0]); 
    1096                 $component = array_pop($component); 
    1097                 $alias = isset($c[1]) ? $c[1] : $component; 
    1098                 $this->_components[$component] = $alias; 
    1099             } 
    1100         } 
    1101  
    1102         foreach ($this->_components as $component => $alias) { 
    1103             if (class_exists($component)) { 
    1104                 $componentObj = Doctrine::getTable($component); 
    1105                 $record = $componentObj->getRecordInstance(); 
     1081        if (Doctrine_Manager::getInstance()->getAttribute('use_dql_callbacks')) { 
     1082            $callback = $this->_getDqlCallback(); 
     1083 
     1084            // if there is no callback for the query type, then we can return early 
     1085            if ( ! $callback) { 
     1086                return; 
     1087            } 
     1088 
     1089            $copy = $this->copy(); 
     1090            $copy->getSqlQuery(); 
     1091 
     1092            foreach ($copy->getQueryComponents() as $alias => $component) { 
     1093                $table = $component['table']; 
     1094                $record = $table->getRecordInstance(); 
    11061095 
    11071096                // check (and call) preDql*() callback on the model class 
     
    11131102                $params = array('component`' => $component, 'alias' => $alias); 
    11141103                $event = new Doctrine_Event($record, $callback['const'], $this, $params); 
    1115                 $componentObj->getRecordListener()->$callback['callback']($event); 
     1104                $table->getRecordListener()->$callback['callback']($event); 
    11161105            } 
    11171106        } 
  • branches/0.11/lib/Doctrine/Template/Listener/SoftDelete.php

    r4439 r4496  
    5151    public function __construct(array $options) 
    5252    { 
     53        // Enable dql callbacks since this event listener utilizes them 
     54        Doctrine_Manager::getInstance()->setAttribute('use_dql_callbacks', true); 
     55 
    5356        $this->_options = $options; 
    5457    }