/** * Force creation of a singleton * * @param ObjectConfig $config A ObjectConfig object with configuration options * @param ObjectManagerInterface $manager A ObjectInterface object * @return DispatcherRequest */ public static function getInstance(ObjectConfig $config, ObjectManagerInterface $manager) { if (!$manager->isRegistered('dispatcher.request')) { $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('dispatcher.request', $config->object_identifier); $manager->registerAlias('request', 'dispatcher.request'); } return $manager->getObject('dispatcher.request'); }
/** * Force creation of a singleton * * @param ObjectConfig $config A ObjectConfig object with configuration options * @param ObjectManagerInterface $manager A ObjectInterface object * @return DispatcherRequest */ public static function getInstance(ObjectConfig $config, ObjectManagerInterface $manager) { if (!$manager->isRegistered('user.session')) { $classname = $config->object_identifier->classname; $instance = new $classname($config); $manager->setObject($config->object_identifier, $instance); $manager->registerAlias('user.session', $config->object_identifier); } return $manager->getObject('user.session'); }
/** * Force creation of a singleton * * @param ObjectConfig $config A ObjectConfig object with configuration options * @param ObjectManagerInterface $manager A ObjectInterface object * @return DispatcherInterface */ public static function getInstance(ObjectConfigInterface $config, ObjectManagerInterface $manager) { //Add the object alias to allow easy access to the singleton $manager->registerAlias($config->object_identifier, 'dispatcher.fragment'); //Merge alias configuration into the identifier $config->append($manager->getIdentifier('dispatcher.fragment')->getConfig()); //Instantiate the class $instance = new static($config); return $instance; }