Changeset 4865
- Timestamp:
- 08/29/08 21:01:19 (10 months ago)
- Location:
- branches/1.0/lib/Doctrine
- Files:
-
- 4 modified
-
Event.php (modified) (2 diffs)
-
Record.php (modified) (2 diffs)
-
Record/Listener.php (modified) (1 diff)
-
Record/Listener/Chain.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/lib/Doctrine/Event.php
r4494 r4865 65 65 const RECORD_SERIALIZE = 25; 66 66 const RECORD_UNSERIALIZE = 26; 67 const RECORD_DQL_DELETE = 27; 67 68 const RECORD_DQL_SELECT = 28; 68 const RECORD_DQL_DELETE = 27;69 69 const RECORD_DQL_UPDATE = 29; 70 const RECORD_VALIDATE = 30; 70 71 71 72 /** … … 192 193 case self::RECORD_DQL_UPDATE: 193 194 return 'update records'; 195 case self::RECORD_VALIDATE: 196 return 'validate record'; 194 197 } 195 198 } -
branches/1.0/lib/Doctrine/Record.php
r4853 r4865 286 286 287 287 // Run validation process 288 $validator = new Doctrine_Validator(); 289 $validator->validateRecord($this); 290 $this->validate(); 291 if ($this->_state == self::STATE_TDIRTY || $this->_state == self::STATE_TCLEAN) { 292 $this->validateOnInsert(); 293 } else { 294 $this->validateOnUpdate(); 295 } 288 $event = new Doctrine_Event($this, Doctrine_Event::RECORD_VALIDATE); 289 $this->preValidate($event); 290 $this->getTable()->getRecordListener()->preValidate($event); 291 292 if ( ! $event->skipOperation) { 293 294 $validator = new Doctrine_Validator(); 295 $validator->validateRecord($this); 296 $this->validate(); 297 if ($this->_state == self::STATE_TDIRTY || $this->_state == self::STATE_TCLEAN) { 298 $this->validateOnInsert(); 299 } else { 300 $this->validateOnUpdate(); 301 } 302 } 303 304 $this->getTable()->getRecordListener()->postValidate($event); 305 $this->postValidate($event); 296 306 297 307 return $this->getErrorStack()->count() == 0 ? true : false; … … 408 418 */ 409 419 public function postInsert($event) 420 { } 421 422 /** 423 * Empty template method to provide concrete Record classes with the possibility 424 * to hook into the validation procedure. Useful for cleaning up data before 425 * validating it. 426 */ 427 public function preValidate($event) 428 { } 429 /** 430 * Empty template method to provide concrete Record classes with the possibility 431 * to hook into the validation procedure. 432 */ 433 public function postValidate($event) 410 434 { } 411 435 -
branches/1.0/lib/Doctrine/Record/Listener.php
r4478 r4865 83 83 public function postHydrate(Doctrine_Event $event) 84 84 { } 85 86 public function preValidate(Doctrine_Event $event) 87 { } 88 89 public function postValidate(Doctrine_Event $event) 90 { } 85 91 } -
branches/1.0/lib/Doctrine/Record/Listener/Chain.php
r4612 r4865 207 207 } 208 208 } 209 210 public function preValidate(Doctrine_Event $event) 211 { 212 foreach ($this->_listeners as $listener) { 213 $listener->preValidate($event); 214 } 215 } 216 217 public function postValidate(Doctrine_Event $event) 218 { 219 foreach ($this->_listeners as $listener) { 220 $listener->postValidate($event); 221 } 222 } 209 223 }