/** * instance * * The singleton class uses the instance() method to return the instance of the NotificationManager. * * @param null $manager Possible different manager. (Helpfull for testing). * @return NotificationManager */ public static function instance($manager = null) { if ($manager instanceof NotificationManager) { static::$_generalManager = $manager; } if (empty(static::$_generalManager)) { static::$_generalManager = new NotificationManager(); } return static::$_generalManager; }
/** * Returns the globally available instance of a Cake\Event\EventManager * 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 the first parameter, it will be set as the globally available instance * * @param \Cake\Event\EventManager $manager Event manager instance. * @return \Cake\Event\EventManager the global event manager */ public static function instance($manager = null) { if ($manager instanceof EventManager) { static::$_generalManager = $manager; } if (empty(static::$_generalManager)) { static::$_generalManager = new EventManager(); } static::$_generalManager->_isGlobal = true; return static::$_generalManager; }
/** * instance * * @param \CMS\Utility\PathManager $manager * @return \CMS\Utility\PathManager */ public static function instance($manager = null) { self::_validate(); if ($manager instanceof PathManager) { static::$_generalManager = $manager; } if (empty(static::$_generalManager)) { static::$_generalManager = new PathManager(); } return static::$_generalManager; }
/** * 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 the first parameter, it will be set as the globally available instance * * @param CakeEventManager $manager Optional event manager instance. * * @return CakeEventManager the global event manager */ public static function instance($manager = NULL) { if ($manager instanceof CakeEventManager) { static::$_generalManager = $manager; } if (empty(static::$_generalManager)) { static::$_generalManager = new CakeEventManager(); } static::$_generalManager->_isGlobal = TRUE; return static::$_generalManager; }