/** * Force creation of a singleton. * * @param KConfigInterface $config An optional KConfig object with configuration options * @param KServiceInterface $container A KServiceInterface object * * @return KServiceInstantiatable */ public static function getInstance(KConfigInterface $config, KServiceInterface $container) { if (!$container->has($config->service_identifier)) { $classname = $config->service_identifier->classname; $instance = new $classname($config); $container->set($config->service_identifier, $instance); $container->setAlias('application.dispatcher', $config->service_identifier); } return $container->get($config->service_identifier); }
/** * Force creation of a singleton. * * @param KConfigInterface $config An optional KConfig object with configuration options * @param KServiceInterface $container A KServiceInterface object * * @return KServiceInstantiatable */ public static function getInstance(KConfigInterface $config, KServiceInterface $container) { if (!$container->has($config->service_identifier)) { $classname = $config->service_identifier->classname; $instance = new $classname($config); $container->set($config->service_identifier, $instance); //Add the service alias to allow easy access to the singleton $container->setAlias('component.dispatcher', $config->service_identifier); } return $container->get($config->service_identifier); }
/** * Force creation of a singleton * * @param object An optional KConfig object with configuration options * @param object A KServiceInterface object * @return KDispatcherDefault */ public static function getInstance(KConfigInterface $config, KServiceInterface $container) { // Check if an instance with this identifier already exists or not if (!$container->has($config->service_identifier)) { //Create the singleton $classname = $config->service_identifier->classname; $instance = new $classname($config); $container->set($config->service_identifier, $instance); //Add the factory map to allow easy access to the singleton $container->setAlias('dispatcher', $config->service_identifier); } return $container->get($config->service_identifier); }