Changeset 4496
- Timestamp:
- 06/08/08 20:55:26 (13 months ago)
- Location:
- branches/0.11/lib
- Files:
-
- 5 modified
-
Doctrine.php (modified) (1 diff)
-
Doctrine/Configurable.php (modified) (1 diff)
-
Doctrine/Manager.php (modified) (1 diff)
-
Doctrine/Query/Abstract.php (modified) (2 diffs)
-
Doctrine/Template/Listener/SoftDelete.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/lib/Doctrine.php
r4446 r4496 196 196 const ATTR_RECURSIVE_MERGE_FIXTURES = 162; 197 197 const ATTR_SINGULARIZE_IMPORT = 163; 198 const ATTR_USE_DQL_CALLBACKS = 164; 198 199 199 200 /** -
branches/0.11/lib/Doctrine/Configurable.php
r4317 r4496 182 182 case Doctrine::ATTR_RECURSIVE_MERGE_FIXTURES; 183 183 case Doctrine::ATTR_SINGULARIZE_IMPORT; 184 case Doctrine::ATTR_USE_DQL_CALLBACKS; 184 185 185 186 break; -
branches/0.11/lib/Doctrine/Manager.php
r4363 r4496 102 102 Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE => 'doctrine', 103 103 Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES => false, 104 Doctrine::ATTR_USE_DQL_CALLBACKS => false, 104 105 ); 105 106 foreach ($attributes as $attribute => $value) { -
branches/0.11/lib/Doctrine/Query/Abstract.php
r4491 r4496 1079 1079 $this->_preQueried = true; 1080 1080 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(); 1106 1095 1107 1096 // check (and call) preDql*() callback on the model class … … 1113 1102 $params = array('component`' => $component, 'alias' => $alias); 1114 1103 $event = new Doctrine_Event($record, $callback['const'], $this, $params); 1115 $ componentObj->getRecordListener()->$callback['callback']($event);1104 $table->getRecordListener()->$callback['callback']($event); 1116 1105 } 1117 1106 } -
branches/0.11/lib/Doctrine/Template/Listener/SoftDelete.php
r4439 r4496 51 51 public function __construct(array $options) 52 52 { 53 // Enable dql callbacks since this event listener utilizes them 54 Doctrine_Manager::getInstance()->setAttribute('use_dql_callbacks', true); 55 53 56 $this->_options = $options; 54 57 }