Force creation of a singleton.

@param AnConfigInterface  $config    An optional AnConfig object with configuration options
@param AnServiceInterface $container A AnServiceInterface object

@return AnServiceInstantiatable
506102
public static function getInstance(AnConfigInterface $config, AnServiceInterface $container)
     {
         if (! $container->has($config->service_identifier)) {

             $person = null;

             if (PHP_SAPI != 'cli') {
                $session = AnService::get('com:sessions');
                $person = $session->has('person') ? $session->get('person') : null;
             }

             $repository = AnService::get('repos:people.person');

             if(isset($person->id)) {
                 $viewer = $repository->find(array('id' => $person->id));
             } else {

                 $viewer = $repository
                 ->getEntity()
                 ->setData(array(
                    'id' => 0,
                    'usertype' => ComPeopleDomainEntityPerson::USERTYPE_GUEST
                 ))->reset();

                 $viewer->getRepository()->extract($viewer);
             }

             $container->set($config->service_identifier, $viewer);
         }

         return $container->get($config->service_identifier);
     }
310279
protected function createIdGenerator(Container $container, array $config)
    {
        $className = array_pull($config, 'class', IdGenerator::class);

        return $container->make($className);
    }
117274
protected function _initialize(AnConfig $config)
    {
		$config->append(array(
			'state' => self::STATE_ACTIVE,
			'expire' => LibSessionsDomainEntitySession::MAX_LIFETIME + time(),
			'security' => array('fix_browser'),
			'force_ssl' => is_ssl(),
			'namespace' => '__anahita',
			'storage' => 'database'
		));

		parent::_initialize($config);
	}
526049
private function createResolver(array $config, ContainerInterface $container)
    {
        $resolvers = [];
        if (isset($config['resolvers'])) {
            $resolvers = $this->createResolvers($config['resolvers'], $container);
        }

        $aggregate = new Resolver\AggregateResolver();
        foreach ($resolvers as $resolver) {
            $aggregate->attach($resolver);
        }

        if ($aggregate->hasType(Resolver\DefaultResolver::class)) {
            $defaultResolver = $aggregate->fetchByType(Resolver\DefaultResolver::class);
        } else {
            $defaultResolver = new Resolver\DefaultResolver();
            $aggregate->attach($defaultResolver, 0);
        }

        if (isset($config['paths']) && is_array($config['paths'])) {
            $this->injectResolverPaths($config['paths'], $defaultResolver);
        }

        if (isset($config['suffix']) && is_string($config['suffix']) && ! empty($config['suffix'])) {
            $defaultResolver->setSuffix($config['suffix']);
        }

        if (isset($config['separator']) && is_string($config['separator']) && ! empty($config['separator'])) {
            $defaultResolver->setSeparator($config['separator']);
        }

        return $aggregate;
    }
974783
protected function _initialize(AnConfig $config)
    {
        $config->append(array(
            'priority' => AnCommand::PRIORITY_LOWEST,
            'validator' => $this->_repository->getIdentifier()->name,
        ));

        parent::_initialize($config);
    }
775852
public static function createServiceManager(array $config = [])
    {
        $serviceManager = new ServiceManager(new Config($config));

        $serviceManager->addInitializer(
            function ($instance, ServiceLocatorInterface $serviceLocator) {
                if ($instance instanceof ModelManagerAwareInterface) {
                    $instance->setModelManager($serviceLocator->get('modelmanager'));
                }
            }
        );

        $serviceManager->addInitializer(
            function ($instance, ServiceLocatorInterface $serviceLocator) {
                if ($instance instanceof ServiceLocatorAwareInterface) {
                    $instance->setServiceLocator($serviceLocator);
                }
            }
        );

        return $serviceManager;
    }
193351
public static function getInstance(Configuration $config = null)
    {
        if (!self::$instance) {
            self::$instance = new self($config);
        }

        return self::$instance;
    }
1019435
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        if ($this->container !== null) {
            return $this->container;
        }

        $builder = new ContainerBuilder();
        $config = $this->getConfig($serviceLocator);
        $configFile = $this->getDefinitionsFilePath($config);
        $builder->addDefinitions($configFile);

        $useAnnotations = $this->shouldUseAnnotations($config);
        $builder->useAnnotations($useAnnotations);

        $acclimator = new ContainerAcclimator();
        $zfContainer = $acclimator->acclimate($serviceLocator);
        $builder->wrapContainer($zfContainer);

        /**
         * @var $cache Cache
         */
        $cache = $this->getCache($serviceLocator, $config);

        if ($cache) {
            $builder->setDefinitionCache($cache);
        }

        $this->container = $builder->build();

        return $this->container;
    }
692233
public function load(ContainerBuilder $container, array $config)
    {
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/config'));
        $loader->load('services.xml');

        if (!empty($config['path'])) {
            if (isset($config['path']['resources'])) {
                $container->setParameter('paths.resources.resource', $config['path']['resources']);
            }

            if (isset($config['path']['base'])) {
                $container->setParameter('paths.resources.base', $config['path']['base']);
            }
        }

        if (!empty($config['resource_map'])) {
            $container->setParameter('resource.map', $config['resource_map']);
        }
    }
177907
private function registerServices(ContainerBuilder $container, $config)
    {
        if ($config['annotation']['enabled']) {
            $this->verifyDoctrineBridgeExists('annotation');
            $container->register('cache.service.annotation', DoctrineCacheBridge::class)
                ->setFactory([DoctrineBridgeFactory::class, 'get'])
                ->addArgument(new Reference($config['annotation']['service_id']))
                ->addArgument($config['annotation'])
                ->addArgument(['annotation']);
        }

        if ($config['serializer']['enabled']) {
            $this->verifyDoctrineBridgeExists('serializer');
            $container->register('cache.service.serializer', DoctrineCacheBridge::class)
                ->setFactory([DoctrineBridgeFactory::class, 'get'])
                ->addArgument(new Reference($config['serializer']['service_id']))
                ->addArgument($config['serializer'])
                ->addArgument(['serializer']);
        }

        if ($config['validation']['enabled']) {
            $container->register('cache.service.validation', SymfonyValidatorBridge::class)
                ->setFactory([ValidationFactory::class, 'get'])
                ->addArgument(new Reference($config['validation']['service_id']))
                ->addArgument($config['validation']);
        }

        if ($config['session']['enabled']) {
            $container->register('cache.service.session', Psr6SessionHandler::class)
                ->setFactory([SessionHandlerFactory::class, 'get'])
                ->addArgument(new Reference($config['session']['service_id']))
                ->addArgument($config['session']);
        }

        if ($config['router']['enabled']) {
            $container->register('cache.service.router', CachingRouter::class)
                ->setFactory([RouterFactory::class, 'get'])
                ->setDecoratedService('router', null, 10)
                ->addArgument(new Reference($config['router']['service_id']))
                ->addArgument(new Reference('cache.service.router.inner'))
                ->addArgument($config['router']);
        }
    }
706676
protected function _initialize(AnConfig $config)
    {
        $config->append(array(
            'repository' => $config->mixer->getIdentifier()->name,
            'priority' => AnCommand::PRIORITY_HIGHEST,
        ));

        parent::_initialize($config);
    }
789659
public static function getInstance(array $config = array(), DriverInterface $driver = null)
    {
        static $instance = null;

        if (null === $instance) {
            $instance = new static();
        }

        if ($config) {
            $instance->config = $config;
        }

        if ($driver) {
            $instance->driver = $driver;
        }

        return $instance;
    }
1234141
private function _createContainer(Config $config = null)
	{
		$container = new Container();

		if ( isset($config) ) {
			$container['config'] = $config;
		}

		return $container;
	}
887197
protected function _initialize(AnConfig $config)
    {
        $base = clone AnRequest::base();

        foreach (array('host', 'scheme', 'port', 'user', 'pass') as $part) {
            $base->$part = AnRequest::url()->$part;
        }

        if (PHP_SAPI == 'cli') {
            $base->scheme = extension_loaded('openssl') ? 'https' : 'http';
            $settings = $this->getService('com:settings.setting');
            $base->host = AnRequest::get('server.HOSTNAME', 'url', $settings->live_site);
            $base->path = '';
        }

        $config->append(array(
            'base_url' => $base,
            'enable_rewrite' => false,
            'url' => clone AnService::get('anahita:http.url')
        ));

        parent::_initialize($config);
    }
1017017
public function register(ContainerInterface $container, Configurable $config)
    {
        if ( ! $config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }

        $requestFilter = new RequestFilter($config);

        $container->add($config->getServiceName(), $requestFilter);
    }
488772
public static function getInstance(AnConfigInterface $config, AnServiceInterface $container)
    {
        if (is_null(self::$_clone)) {
            self::$_clone = new AnRegistry();
        }

        if ($config->key) {
            $config->cache_prefix .= '-'.$config->key;
            unset($config->key);
        }

        if (! isset(self::$_instances[$config->cache_prefix])) {

            $instance = clone self::$_clone;
            self::$_instances[$config->cache_prefix] = $instance;

            $instance->setCachePrefix($config->cache_prefix);
            $instance->enableCache($config->cache_enabled);
        }

        return self::$_instances[$config->cache_prefix];
    }
1294228
public static function getInstance(AnConfigInterface $config, AnServiceInterface $container)
    {
        if (!$container->has($config->service_identifier)) {
            $registry = $container->get('application.registry', array('key' => $config->service_identifier));

            if (!$registry->offsetExists('aggregations')) {
                $components = $container->get('repos:components.component')->fetchSet();

                $dispatcher = $container->get('anahita:event.dispatcher');
                $components->registerEventDispatcher($dispatcher);

                $aggregations = new AnConfig();
                $event = new AnEvent(array('aggregations' => $aggregations));

                $dispatcher->dispatchEvent('onStoryAggregation', $event);
                $registry->offsetSet('aggregations', $aggregations);
            }

            $container->set($config->service_identifier, $registry->offsetGet('aggregations'));
        }

        return $container->get($config->service_identifier);
    }