]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
simplify SqlProfiler
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 8 Jun 2013 16:35:08 +0000 (19:35 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 8 Jun 2013 16:35:08 +0000 (19:35 +0300)
ipf/orm/connection.php
ipf/orm/connection/profiler.php

index ce3745797a68f2eeba8fe78692f4f273c666c439..0d161a0aa0db350d789ab12fbb0c742f43fa7d27 100644 (file)
@@ -853,7 +853,7 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta
     public function notifyDBListeners($method, $event)
     {
         foreach ($this->dbListeners as $listener)
-            if (method_exists($listener, $method))
+            if (is_callable(array($listener, $method)))
                 $listener->$method($event);
     }
 }
index 6230025f8d78c7284443f64b9309f44ca39f78bc..4284fcbbf8ef0808c551125a1b74825f8ff00f84 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-class IPF_ORM_Connection_Profiler implements IPF_ORM_Overloadable, IteratorAggregate, Countable
+class IPF_ORM_Connection_Profiler
 {
     private $listeners  = array('query',
                                 'prepare',
@@ -11,19 +11,12 @@ class IPF_ORM_Connection_Profiler implements IPF_ORM_Overloadable, IteratorAggre
                                 'exec',
                                 'execute');
 
-    private $events     = array();
-    public function __construct() {
-    }
-
-    public function setFilterQueryType() {
-    }                                         
+    public $events = array();
 
     public function __call($m, $a)
     {
-        if ( ! ($a[0] instanceof IPF_ORM_Event)) {
-            throw new IPF_ORM_Exception_Profiler("Couldn't listen event. Event should be an instance of IPF_Event.");
-        }
-
+        if (!($a[0] instanceof IPF_ORM_Event))
+            return;
 
         if (substr($m, 0, 3) === 'pre') {
             // pre-event listener found
@@ -36,54 +29,6 @@ class IPF_ORM_Connection_Profiler implements IPF_ORM_Overloadable, IteratorAggre
             // after-event listener found
             $a[0]->end();
         }
-        /**
-         * If filtering by query type is enabled, only keep the query if
-         * it was one of the allowed types.
-         */
-         /*
-        if ( !is_null($this->filterTypes)) {
-            if ( ! ($a[0]->getQueryType() & $this->_filterTypes)) {
-
-            }
-        }
-        */
-    }
-
-    public function get($key) 
-    {
-        if (isset($this->events[$key])) {
-            return $this->events[$key];
-        }
-        return null;
-    }
-
-    public function getAll() 
-    {
-        return $this->events;
     }
+}
 
-    public function getIterator()
-    {
-        return new ArrayIterator($this->events);
-    }
-
-    public function count() 
-    {
-        return count($this->events);
-    }
-
-    public function pop() 
-    {
-        return array_pop($this->events);
-    }
-
-    public function lastEvent()
-    {
-        if (empty($this->events)) {
-            return false;
-        }
-
-        end($this->events);
-        return current($this->events);
-    }
-}
\ No newline at end of file