Debugger.class.php 5.68 KB
Newer Older
doctrine's avatar
doctrine committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
<?php
require_once("EventListener.class.php");

class Doctrine_DebugMessage {
    private $code;
    private $object;
    public function __construct($object, $code) {
        $this->object = $object;
        $this->code   = $code;
    }
    final public function getCode() {
        return $this->code;
    }
    final public function getObject() {
        return $this->object;
    }
}
class Doctrine_Debugger extends Doctrine_EventListener {
    const EVENT_LOAD            = 1;
    const EVENT_PRELOAD         = 2;
    const EVENT_SLEEP           = 3;
    const EVENT_WAKEUP          = 4;
    const EVENT_UPDATE          = 5;
    const EVENT_PREUPDATE       = 6;
    const EVENT_CREATE          = 7;
    const EVENT_PRECREATE       = 8;

    const EVENT_SAVE            = 9;
    const EVENT_PRESAVE         = 10;
    const EVENT_INSERT          = 11;
    const EVENT_PREINSERT       = 12;
    const EVENT_DELETE          = 13;
    const EVENT_PREDELETE       = 14;
    const EVENT_EVICT           = 15;
    const EVENT_PREEVICT        = 16;
    const EVENT_CLOSE           = 17;
    const EVENT_PRECLOSE        = 18;

    const EVENT_OPEN            = 19;
    const EVENT_COMMIT          = 20;
    const EVENT_PRECOMMIT       = 21;
    const EVENT_ROLLBACK        = 22;
    const EVENT_PREROLLBACK     = 23;
    const EVENT_BEGIN           = 24;
    const EVENT_PREBEGIN        = 25;
    const EVENT_COLLDELETE      = 26;
    const EVENT_PRECOLLDELETE   = 27;
    private $debug;
    
    public function getMessages() {
        return $this->debug;                              	
    }


    public function onLoad(Doctrine_Record $record) {
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_LOAD);
    }
    public function onPreLoad(Doctrine_Record $record) {
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRELOAD);
    }

    public function onSleep(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_SLEEP);
    }

    public function onWakeUp(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_WAKEUP);
    }

    public function onUpdate(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_UPDATE);
    }
    public function onPreUpdate(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREUPDATE);
    }

    public function onCreate(Doctrine_Record $record) {
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_CREATE);
    }
    public function onPreCreate(Doctrine_Record $record) {
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRECREATE);
    }

    public function onSave(Doctrine_Record $record) {
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_SAVE);
    }
    public function onPreSave(Doctrine_Record $record) {
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PRESAVE);
    }

    public function onInsert(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_INSERT);
    }
    public function onPreInsert(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREINSERT);
    }

    public function onDelete(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_DELETE);
    }
    public function onPreDelete(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREDELETE);
    }

    public function onEvict(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_EVICT);
    }
    public function onPreEvict(Doctrine_Record $record) { 
        $this->debug[] = new Doctrine_DebugMessage($record,self::EVENT_PREEVICT);
    }

    public function onClose(Doctrine_Session $session) { 
         $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_CLOSE);
    }
    public function onPreClose(Doctrine_Session $session) { 
         $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_PRECLOSE);
    }

    public function onOpen(Doctrine_Session $session) { 
         $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_OPEN);
    }

    public function onTransactionCommit(Doctrine_Session $session) { 
         $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_COMMIT);
    }
    public function onPreTransactionCommit(Doctrine_Session $session) { 
        $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_PRECOMMIT);
    }

    public function onTransactionRollback(Doctrine_Session $session) {
        $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_ROLLBACK);
    }
    public function onPreTransactionRollback(Doctrine_Session $session) {
        $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_PREROLLBACK);
    }

    public function onTransactionBegin(Doctrine_Session $session) {
        $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_BEGIN);
    }
    public function onPreTransactionBegin(Doctrine_Session $session) {
        $this->debug[] = new Doctrine_DebugMessage($session,self::EVENT_PREBEGIN);
    }
    
    public function onCollectionDelete(Doctrine_Collection $collection) { 
        $this->debug[] = new Doctrine_DebugMessage($collection,self::EVENT_COLLDELETE);
    }
    public function onPreCollectionDelete(Doctrine_Collection $collection) {
        $this->debug[] = new Doctrine_DebugMessage($collection,self::EVENT_PRECOLLDELETE);
    }
}
?>