Explorar o código

Added a new method to check if an event has any listeners registered.

Max Gfeller %!s(int64=11) %!d(string=hai) anos
pai
achega
067a8e764f
Modificáronse 1 ficheiros con 13 adicións e 0 borrados
  1. 13 0
      src/Composer/EventDispatcher/EventDispatcher.php

+ 13 - 0
src/Composer/EventDispatcher/EventDispatcher.php

@@ -220,6 +220,19 @@ class EventDispatcher
         return call_user_func_array('array_merge', $listeners[$event->getName()]);
     }
 
+    /**
+     * Checks if an event has listeners registered
+     *
+     * @param Event $event
+     * @return boolean
+     */
+    public function hasEventListeners(Event $event)
+    {
+        $listeners = $this->getListeners($event);
+
+        return (sizeof($listeners) > 0);
+    }
+
     /**
      * Finds all listeners defined as scripts in the package
      *