Force creation of a singleton.

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

@return AnServiceInstantiatable
435927
public static function getInstance(AnConfigInterface $config, AnServiceInterface $container)
    {
        $strIdentifier = (string) $config->service_identifier;
        $registery = $container->get('application.registry', array('key' => $strIdentifier.'_default_class'));

        if (!$registery->offsetExists($strIdentifier)) {
            try {
                $identifier = clone $config->service_identifier;
                $identifier->type = 'repos';
                $identifier->path = array('domain','entity');
                $default = array(
                    'prefix' => $container->get($identifier)->getClone(),
                    'fallback' => 'ComBaseControllerDefault',
                    );
            } catch (Exception $e) {
                $default = 'Com'.ucfirst($config->service_identifier->package).'ControllerDefault';
                $default = array(
                  'default' => array(
                      $default,
                      'ComBaseControllerResource',
                      ), );
            }

            $default['identifier'] = $config->service_identifier;
            register_default($default);
            $classname = AnServiceClass::findDefaultClass($config->service_identifier);
            $config->service_identifier->classname = $classname;
            $registery->offsetSet($strIdentifier, $classname);
        }

        $classname = $registery->offsetGet($strIdentifier);
        $instance = new $classname($config);

        return $instance;
    }
1038884
protected function _initialize(AnConfig $config)
    {
        $config->append(array(
            'resources' => array('subscriptions_packages'),
            'attributes' => array(
                'name' => array('required' => true),
                'body' => array('format' => 'html'),
                'price' => array(
                    'type' => 'float',
                    'required' => true,
                ),
                'duration' => array(
                    'type' => 'integer',
                    'required' => true,
                ),
                'recurring' => array(
                    'type' => 'integer',
                    'default' => 0,
                ),
                'billingPeriod' => array(
                    'default' => self::BILLING_PERIOD_YEAR,
                    'required' => true,
                ),
            ),
            'relationships' => array(
                //let the cleaner to take care of it
                'subscriptions' => array(
                    'parent_delete' => 'ignore',
                 ),
            ),
            'behaviors' => array(
                'authorizer',
                'orderable',
                'describable',
                'enableable',
                'dictionariable',
                'modifiable',
            ),
        ));

        parent::_initialize($config);
    }
766197
public function configureClass($config, ContainerBuilder $container)
    {
        // admin configuration
        $container->setParameter('networking_init_cms.admin.page.class', $config['class']['page']);
        $container->setParameter('networking_init_cms.admin.layout_block.class', $config['class']['layout_block']);
        $container->setParameter('networking_init_cms.admin.user.class', $config['class']['user']);

        // manager configuration
        $container->setParameter('networking_init_cms.manager.page.class', $config['class']['page']);
        $container->setParameter('networking_init_cms.manager.layout_block.class', $config['class']['layout_block']);
        $container->setParameter('networking_init_cms.manager.user.class', $config['class']['user']);

        switch ($config['db_driver']) {
            case 'orm':
                $container->setParameter('networking_init_cms.admin.layout_block.class', 'Networking\InitCmsBundle\Entity\LayoutBlock');
                break;
            case 'mongodb':
                $container->setParameter('networking_init_cms.admin.layout_block.class', 'Networking\InitCmsBundle\Docment\LayoutBlock');
                break;
            default:
                throw new \InvalidArgumentException('db driver must be either orm or mongodb');
                break;
        }
    }
58028
private function loadServices(array $config, ContainerBuilder $container)
    {
        if ('fos_user.util.canonicalizer.default' === $config['service']['username_canonicalizer']) {
            $config['service']['username_canonicalizer'] = 'fos_user.util.username_canonicalizer';
        }

        if ('fos_user.util.canonicalizer.default' === $config['service']['email_canonicalizer']) {
            $config['service']['email_canonicalizer'] = 'fos_user.util.email_canonicalizer';
        }

        // Only create a UserManager service when not using a custom one
        if ('fos_user.user_manager.default' === $config['service']['user_manager']) {
            $config['service']['user_manager'] = $this->createUserManager($config, $container);
        }

        if (sprintf('%s.user_manager', $this->servicePrefix) !== $config['service']['user_manager']) {
            $container->setAlias(sprintf('%s.user_manager', $this->servicePrefix), $config['service']['user_manager']);
        }

        $container->setDefinition(sprintf('%s.user_provider.username', $this->servicePrefix), new DefinitionDecorator('fos_user.user_provider.username'))
        ->replaceArgument(0, new Reference(sprintf('%s.user_manager', $this->servicePrefix)))
        ->setPublic(false);

        $container->setDefinition(sprintf('%s.user_provider.username_email', $this->servicePrefix), new DefinitionDecorator('fos_user.user_provider.username_email'))
        ->replaceArgument(0, new Reference(sprintf('%s.user_manager', $this->servicePrefix)))
        ->setPublic(false);

        $container->setDefinition(sprintf('%s.user_manipulator', $this->servicePrefix), new DefinitionDecorator('fos_user.util.user_manipulator'))
        ->replaceArgument(0, new Reference(sprintf('%s.user_manager', $this->servicePrefix)));

        $container->setDefinition(sprintf('%s.listener.authentication', $this->servicePrefix), new DefinitionDecorator('fos_user.listener.authentication'))
        ->replaceArgument(1, sprintf('%%%s.firewall_name%%', $this->servicePrefix))
        ->addTag('kernel.event_subscriber');
    }
293944
public static function getInstance(AnConfigInterface $config, AnServiceInterface $container)
    {
        AnService::get('com:plugins.helper')->import('storage');

        if (!$container->has($config->service_identifier)) {
            $classname = $config->service_identifier->classname;
            $instance = new PlgStorageLocal($config);
            $container->set($config->service_identifier, $instance);
        }

        return $container->get($config->service_identifier);
    }
253731
protected function registerBindings(Container $container, ConfigRepository $config)
    {
        $container->bind(OAuth2Service::class, function ($container) use ($config) {
            return $this->createService($container, $config[self::CONFIG_KEY]);
        });

        $container->alias(OAuth2Service::class, OAuth2ServiceContract::class);
    }
957343
public function configure(array $config, ConfigurationInterface $configuration, ContainerBuilder $container)
    {
        $processor = new Processor();
        $config    = $processor->processConfiguration($configuration, $config);

        $loader = new XmlFileLoader($container, new FileLocator($this->getConfigurationDirectory()));

		foreach(WallPosterBundle::getAvailableProviders() as $service)
		{
			if(isset($config[$service]))
			{
				$this->mapParameters($service, $config[$service], $container);
				$this->loadConfigurationFile($service,$loader);
			}
		}

        return array($config, $loader);
    }
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);
    }
358476
public static function instance($config = [])
    {
        if (null === self::$instance) {
            self::$instance = new static($config);
        }

        return self::$instance;
    }
714358
protected function _initialize(AnConfig $config)
    {
        $config->append(array(
            'test_mode' => get_config_value('subscriptions.test_mode', true),
            'login' => get_config_value('subscriptions.login'),
            'password' => get_config_value('subscriptions.password'),
            'signature' => get_config_value('subscriptions.signature')
        ));

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

        $logger = new Logger($config->name, $config->handlers);

        $container->add($config->getServiceName(), $logger);
    }
751413
public function getConfiguration(array $config, ContainerBuilder $container)
    {
        $configuration = new Configuration($this->getMainConfigParser(), $this->suggestionCollector);
        $configuration->setSiteAccessConfigurationFilters($this->siteaccessConfigurationFilters);

        return $configuration;
    }
797197
public function setContainer(ContainerInterface $container)
    {
        $application = $this;
        $container->share(ApplicationInterface::class, $application);
        $container->share(\Interop\Container\ContainerInterface::class, $container);

        $this->container = $container;

        return $this;
    }
58832
public function authorisation(Container $container)
    {
        $auth   = new Authorisation();
        $config = $container->get('config');

        foreach ((array) $config->get('user.policies') as $name => $policy) {
            if ($policy instanceof ClassMeta || (is_string($policy) && class_exists($policy))) {
                $instance = $container->newInstance($policy);

                if (is_subclass_of($instance, PolicyInterface::class)) {
                    $auth->addPolicy($name, $instance);
                } elseif (is_subclass_of($instance, PolicyProviderInterface::class)) {
                    $auth->registerPolicyProvider($instance);
                }
            } elseif ($policy === false) {
                continue;
            } else {
                throw new \InvalidArgumentException(sprintf(
                    'Please register instance of %s or %s',
                    PolicyInterface::class,
                    PolicyProviderInterface::class
                ));
            }
        }

        /** @var EventDispatcher $dispatcher */
        $this->dispatcher->triggerEvent('onLoadAuthorisationPolicies', ['auth' => $auth]);

        return $auth;
    }
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];
    }
979098
protected function loadServices($config, $container)
    {
        if (! isset($config['services'])) {
            return;
        }

        $serviceMethods = array(
            'blob' => 'createBlobService',
            'table' => 'createTableService',
            'queue' => 'createQueueService',
            'service_bus' => 'createServiceBusService',
            'management' => 'createServiceManagementService'
        );

        $serviceClass = array(
            'blob' => 'WindowsAzure\Blob\BlobRestProxy',
            'table' => 'WindowsAzure\Table\TableRestProxy',
            'queue' => 'WindowsAzure\Queue\QueueRestProxy',
            'service_bus' => 'WindowsAzure\ServiceBus\ServiceBusRestProxy',
            'management' => 'WindowsAzure\ServiceManagement\ServiceManagementRestProxy'
        );

        foreach ($config['services'] as $type => $connectionStrings) {
            foreach ($connectionStrings as $name => $connectionString) {
                $def = new Definition($serviceClass[$type]);
                $def->setFactoryService('windows_azure.services_builder');
                $def->setFactoryMethod($serviceMethods[$type]);
                $def->setArguments(array(
                    $connectionString
                ));

                $container->setDefinition(sprintf('windows_azure.%s.%s', $type, $name), $def);
            }
        }
    }
818051
public function get(Container $container)
    {
        if ($this->singleton) {
            if ($this->instance === null) {
                $f = $this->factory;
                $this->instance = $f($container);
            }
            return $this->instance;
        } else {
            $f = $this->factory;
            return $f($container);
        }
    }