Commit 24ca1398 authored by guilhermeblanco's avatar guilhermeblanco

Cosmetics changes in EventManager, renamed the registerEventListener to...

Cosmetics changes in EventManager, renamed the registerEventListener to addEventListener, optimized the source and changed the arguments order. Commented an echo line in RangeVariableDeclaration
parent ad244305
...@@ -6,6 +6,7 @@ class Doctrine_EventManager ...@@ -6,6 +6,7 @@ class Doctrine_EventManager
{ {
private $_listeners = array(); private $_listeners = array();
public function dispatchEvent($event) { public function dispatchEvent($event) {
$argIsCallback = is_string($event); $argIsCallback = is_string($event);
$callback = $argIsCallback ? $event : $event->getType(); $callback = $argIsCallback ? $event : $event->getType();
...@@ -20,23 +21,26 @@ class Doctrine_EventManager ...@@ -20,23 +21,26 @@ class Doctrine_EventManager
return ! $event->getDefaultPrevented(); return ! $event->getDefaultPrevented();
} }
public function getListeners($callback = null) { public function getListeners($callback = null) {
return $callback ? $this->_listeners[$callback] : $this->_listeners; return $callback ? $this->_listeners[$callback] : $this->_listeners;
} }
public function hasListeners($callback) { public function hasListeners($callback) {
return isset($this->_listeners[$callback]); return isset($this->_listeners[$callback]);
} }
public function registerEventListener($listener, $callbacks) {
public function addEventListener($callbacks, $listener) {
// TODO: maybe check for duplicate registrations? // TODO: maybe check for duplicate registrations?
if (is_array($callbacks)) { if ( ! is_array($callbacks)) {
$callbacks = array($callbacks);
}
foreach ($callbacks as $callback) { foreach ($callbacks as $callback) {
$this->_listeners[$callback] = $listener; $this->_listeners[$callback] = $listener;
} }
} else {
$this->_listeners[$callbacks] = $listener;
}
} }
} }
......
...@@ -216,7 +216,7 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_ ...@@ -216,7 +216,7 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_
$parent = $path; $parent = $path;
} catch (Doctrine_Exception $e) { } 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()); $this->_parser->semanticalError($e->getMessage());
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment