From 24ca13980f695cacef31a34a1002ca60d976ff07 Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Sun, 8 Jun 2008 16:42:55 +0000 Subject: [PATCH] Cosmetics changes in EventManager, renamed the registerEventListener to addEventListener, optimized the source and changed the arguments order. Commented an echo line in RangeVariableDeclaration --- lib/Doctrine/EventManager.php | 26 +++++++++++-------- .../Production/RangeVariableDeclaration.php | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/EventManager.php b/lib/Doctrine/EventManager.php index 804b0e648..da8bbd969 100644 --- a/lib/Doctrine/EventManager.php +++ b/lib/Doctrine/EventManager.php @@ -6,10 +6,11 @@ class Doctrine_EventManager { private $_listeners = array(); + public function dispatchEvent($event) { $argIsCallback = is_string($event); $callback = $argIsCallback ? $event : $event->getType(); - + if (isset($this->_listeners[$callback])) { $event = $argIsCallback ? new Doctrine_Event($event) : $event; foreach ($this->_listeners[$callback] as $listener) { @@ -19,23 +20,26 @@ class Doctrine_EventManager return ! $event->getDefaultPrevented(); } - + + public function getListeners($callback = null) { return $callback ? $this->_listeners[$callback] : $this->_listeners; } - + + public function hasListeners($callback) { return isset($this->_listeners[$callback]); } - - public function registerEventListener($listener, $callbacks) { + + + public function addEventListener($callbacks, $listener) { // TODO: maybe check for duplicate registrations? - if (is_array($callbacks)) { - foreach ($callbacks as $callback) { - $this->_listeners[$callback] = $listener; - } - } else { - $this->_listeners[$callbacks] = $listener; + if ( ! is_array($callbacks)) { + $callbacks = array($callbacks); + } + + foreach ($callbacks as $callback) { + $this->_listeners[$callback] = $listener; } } } diff --git a/lib/Doctrine/Query/Production/RangeVariableDeclaration.php b/lib/Doctrine/Query/Production/RangeVariableDeclaration.php index 01ed5ff5b..cebc9f826 100644 --- a/lib/Doctrine/Query/Production/RangeVariableDeclaration.php +++ b/lib/Doctrine/Query/Production/RangeVariableDeclaration.php @@ -216,7 +216,7 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_ $parent = $path; } catch (Doctrine_Exception $e) { - echo "Tried to load class metadata from '".$relationName."'\n"; + //echo "Tried to load class metadata from '".$relationName."'\n"; $this->_parser->semanticalError($e->getMessage()); return;