/** * Returns the globally available instance of a CakeEventManager * this is used for dispatching events attached from outside the scope * other managers were created. Usually for creating hook systems or inter-class * communication * * If called with a first params, it will be set as the globally available instance * * @param CakeEventManager $manager * @return CakeEventManager the global event manager */ public static function instance($manager = null) { if ($manager instanceof CakeEventManager) { self::$_generalManager = $manager; } if (empty(self::$_generalManager)) { self::$_generalManager = new CakeEventManager(); } self::$_generalManager->_isGlobal = true; return self::$_generalManager; }