/** * Force creation of a singleton * * @param object An optional Library\ObjectConfig object with configuration options * @param object A Library\ServiceInterface object * @return KDispatcherDefault */ public static function getInstance(Library\ObjectConfig $config, Library\ObjectManagerInterface $manager) { // Check if an instance with this identifier already exists or not if (!$manager->isRegistered($config->object_identifier)) { $class = $manager->getClass($config->object_identifier); $instance = new $class($config); $manager->setObject($config->object_identifier, $instance); } return $manager->getObject($config->object_identifier); }
public static function getInstance(Library\ObjectConfig $config, Library\ObjectManagerInterface $manager) { // Check if an instance with this identifier already exists if (!$manager->isRegistered('application')) { $classname = $config->object_identifier->classname; $instance = new $classname($config); $manager->setObject($config->object_identifier, $instance); //Add the service alias to allow easy access to the singleton $manager->registerAlias('application', $config->object_identifier); } return $manager->getObject('application'); }
/** * Check for overrides of the filter * * @param Library\ObjectConfig $config An optional Library\ObjectConfig object with configuration options * @param Library\ObjectManagerInterface $manager A Library\ObjectManagerInterface object * @return TemplateHelperChrome */ public static function getInstance(Library\ObjectConfig $config, Library\ObjectManagerInterface $manager) { $identifier = clone $config->object_identifier; $identifier->package = $config->module->package; $identifier = $manager->getIdentifier($identifier); if (file_exists($identifier->classpath)) { $classname = $identifier->classname; } else { $classname = $config->object_identifier->classname; } $instance = new $classname($config); return $instance; }