src/Kisma/Core/Utility/EventManager.php
public static function _discoverObjectListeners( $object, $pattern = self::LISTENER_DISCOVERY_PATTERN, $rediscover = false )
    {
        static $_discovered = array();

        $_listeners = array();

        $_objectId = spl_object_hash( is_string( $object ) ? '_class.' . $object : $object );

        if ( false === $rediscover && isset( $_discovered[$_objectId] ) )
        {
            return true;
        }

        try
        {
            $_mirror = new \ReflectionClass( $object );
            $_methods = $_mirror->getMethods( \ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED );

            //	Check each method for the event handler signature
            foreach ( $_methods as $_method )
            {
                //	Event handler?
                if ( 0 == preg_match( $pattern, $_method->name, $_matches ) || empty( $_matches[1] ) )
                {
                    continue;
                }

                //	Neutralize the name
                $_eventName = Inflector::neutralize( $_matches[1] );

                if ( !isset( $_listeners[$_eventName] ) )
                {
                    $_listeners[$_eventName] = array();
                }

                //	Save off a callable
                $_listeners[$_eventName][] = array($object, $_method->name);

                //	Clean up
                unset( $_matches, $_method );
            }

            unset( $_methods, $_mirror );

            $_discovered[$_objectId] = true;
        }
        catch ( \Exception $_ex )
        {
            return false;
        }

        //	Return the current map
        return $_listeners;
    }
public static function _discoverObjectListeners( $object, $pattern = self::LISTENER_DISCOVERY_PATTERN, $rediscover = false )
    {
        static $_discovered = array();

        $_listeners = array();

        $_objectId = spl_object_hash( is_string( $object ) ? '_class.' . $object : $object );

        if ( false === $rediscover && isset( $_discovered[$_objectId] ) )
        {
            return true;
        }

        try
        {
            $_mirror = new \ReflectionClass( $object );
            $_methods = $_mirror->getMethods( \ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED );

            //	Check each method for the event handler signature
            foreach ( $_methods as $_method )
            {
                //	Event handler?
                if ( 0 == preg_match( $pattern, $_method->name, $_matches ) || empty( $_matches[1] ) )
                {
                    continue;
                }

                //	Neutralize the name
                $_eventName = Inflector::neutralize( $_matches[1] );

                if ( !isset( $_listeners[$_eventName] ) )
                {
                    $_listeners[$_eventName] = array();
                }

                //	Save off a callable
                $_listeners[$_eventName][] = array($object, $_method->name);

                //	Clean up
                unset( $_matches, $_method );
            }

            unset( $_methods, $_mirror );

            $_discovered[$_objectId] = true;
        }
        catch ( \Exception $_ex )
        {
            return false;
        }

        //	Return the current map
        return $_listeners;
    }
public static function _discoverObjectListeners ( $ object , $ pattern = self :: LISTENER_DISCOVERY_PATTERN , $ rediscover = false ) { static $ _discovered = array ( ) ; $ _listeners = array ( ) ; $ _objectId = spl_object_hash ( is_string ( $ object ) ? '_class.' . $ object : $ object ) ; if ( false === $ rediscover && isset ( $ _discovered [ $ _objectId ] ) ) { return true ; } try { $ _mirror = new \ ReflectionClass ( $ object ) ; $ _methods = $ _mirror -> getMethods ( \ ReflectionMethod :: IS_PUBLIC | \ ReflectionMethod :: IS_PROTECTED ) ; //	Check each method for the event handler signature foreach ( $ _methods as $ _method ) { //	Event handler? if ( 0 == preg_match ( $ pattern , $ _method -> name , $ _matches ) || empty ( $ _matches [ 1 ] ) ) { continue ; } //	Neutralize the name $ _eventName = Inflector :: neutralize ( $ _matches [ 1 ] ) ; if ( ! isset ( $ _listeners [ $ _eventName ] ) ) { $ _listeners [ $ _eventName ] = array ( ) ; } //	Save off a callable $ _listeners [ $ _eventName ] [ ] = array ( $ object , $ _method -> name ) ; //	Clean up unset ( $ _matches , $ _method ) ; } unset ( $ _methods , $ _mirror ) ; $ _discovered [ $ _objectId ] = true ; } catch ( \ Exception $ _ex ) { return false ; } //	Return the current map return $ _listeners ; }
Builds a hash of events and handlers that are present in this object based on the event handler signature.
This merely builds the hash, nothing is done with it.

@param \Kisma\Core\Interfaces\SubscriberLike|string $object     The object or class to scan
@param string                                       $pattern    The method listener pattern to scan for
@param bool                                         $rediscover By default, the discoverer will not wire up the same object's events more than
once. Setting $rediscover to TRUE will force the rediscovery of the listeners,
if any. The default is false.

@return array|bool The listeners discovered. True if already discovered, False on error
Builds a hash of events and handlers that are present in this object based on the event handler signature . This merely builds the hash nothing is done with it .