Get db configuration, if any

@param  ServiceLocatorInterface|ContainerInterface $services
@return array
420107
protected function getConfig($services)
    {
        if ($this->config !== null) {
            return $this->config;
        }

        if (!$services->has('Config')) {
            $this->config = [];

            return $this->config;
        }

        $config = $services->get('Config');
        if (!isset($config['sphinxql'])
            || !is_array($config['sphinxql'])
        ) {
            $this->config = [];

            return $this->config;
        }

        $config = $config['sphinxql'];
        if (!isset($config['adapters'])
            || !is_array($config['adapters'])
        ) {
            $this->config = [];

            return $this->config;
        }

        $this->config = $config['adapters'];

        return $this->config;
    }
219904
private static function getORMConfiguration(array $options = array(), LoggerInterface $logger = null, ContainerInterface $container = null)
    {
        $config = new Configuration();

        $driverImpl = $config->newDefaultAnnotationDriver([], false);

        $config->setMetadataDriverImpl($driverImpl);
        $config->setRepositoryFactory(new RepositoryFactory(
            isset($options['orm']) ? (array) $options['orm'] : []
        ));

        if (isset($options['proxy_dir'])) {
            $config->setProxyDir($options['proxy_dir']);
        }

        if (isset($options['proxy_ns'])) {
            $config->setProxyNamespace($options['proxy_ns']);
        }

        if (isset($options['orm'])) {
            if (isset($options['orm']['proxy_namespace'])) {
                $config->setProxyNamespace($options['orm']['proxy_namespace']);
            }

            if (isset($options['orm']['proxy_dir'])) {
                $config->setProxyDir($options['orm']['proxy_dir']);
            }

            if (isset($options['orm']['auto_generate_proxy_classes'])) {
                $config->setAutoGenerateProxyClasses($options['orm']['auto_generate_proxy_classes']);
            }

            if (isset($options['orm']['metadata_cache_driver']) && is_array($options['orm']['metadata_cache_driver'])) {
                if (isset($options['orm']['metadata_cache_driver']['type'])) {
                    if (
                        'service' === $options['orm']['metadata_cache_driver']['type']
                        && isset($options['orm']['metadata_cache_driver']['id'])
                    ) {
                        $service = null;
                        $serviceId = $options['orm']['metadata_cache_driver']['id'];
                        if (is_object($serviceId)) {
                            $service = $serviceId;
                        } elseif (is_string($serviceId)) {
                            $serviceId = str_replace('@', '', $serviceId);
                            if (null !== $container && $container->has($serviceId)) {
                                $service = $container->get($serviceId);
                            }
                        }

                        if (null !== $service) {
                            $config->setMetadataCacheImpl($service);
                        }
                    }
                }
            }

            if (isset($options['orm']['query_cache_driver']) && is_array($options['orm']['query_cache_driver'])) {
                if (isset($options['orm']['query_cache_driver']['type'])) {
                    if (
                        'service' === $options['orm']['query_cache_driver']['type']
                        && isset($options['orm']['query_cache_driver']['id'])
                    ) {
                        $serviceId = str_replace('@', '', $options['orm']['query_cache_driver']['id']);
                        if (null !== $container && $container->has($serviceId)) {
                            $config->setQueryCacheImpl($container->get($serviceId));
                        }
                    }
                }
            }
        }

        if ($logger instanceof SQLLogger) {
            $config->setSQLLogger($logger);
        }

        return self::addCustomFunctions($config, $options);
    }
466738
public function get($service)
    {
        return $this->has($service) ? $this->container->get($service) : null;
    }
764866
protected static function getSessionSettings(ContainerInterface $container): array
    {
        /** @var SettingsProviderInterface $provider */
        $provider = $container->get(SettingsProviderInterface::class);
        $settings = $provider->get(C::class);

        return $settings;
    }
333340
public function describeMany(array $services)
    {
        $descriptions = [];
        foreach ($services as $serviceId) {
            $descriptions[] = $this->describe($serviceId);
        }
        
        return $descriptions;
    }
1125015
public function get(string $id): DatabaseConfiguration
    {
        if (isset($this->configurations[$id])) {
            return $this->configurations[$id];
        }

        throw new \OutOfBoundsException(
                'No database configuration known for database requested with id '
                . $id
        );
    }
318138
public function getServiceIds()
    {
        $ids = array();

        if (!$this->methodMap && !$this instanceof ContainerBuilder && __CLASS__ !== static::class) {
            // We only check the convention-based factory in a compiled container (i.e. a child class other than a ContainerBuilder,
            // and only when the dumper has not generated the method map (otherwise the method map is considered to be fully populated by the dumper)
            @trigger_error('Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', E_USER_DEPRECATED);

            foreach (get_class_methods($this) as $method) {
                if (preg_match('/^get(.+)Service$/', $method, $match)) {
                    $ids[] = self::underscore($match[1]);
                }
            }
        }
        $ids[] = 'service_container';

        return array_unique(array_merge($ids, array_keys($this->methodMap), array_keys($this->fileMap), array_keys($this->services)));
    }
227048
public function initializeConfig($service)
    {
        if (function_exists('config_path') &&
            file_exists(config_path('pushnotification.php')) &&
            function_exists('app')
        ) {
            $configuration = app('config')->get('pushnotification');
        } else {
            $configuration = include(__DIR__ . '/Config/config.php');
        }

        if (!array_key_exists($service, $configuration)) {
            throw new PushNotificationException("Service '$service' missed in config/pushnotification.php");
        }
        return $configuration[$service];
    }
579445
protected function getDatabaseConfig()
    {
        $config = Zend_Controller_Front::getInstance()->getParam('bootstrap');
        $resources = $config->getOption('resources');
        $dbConfig = [
            'driver'   => $resources['db']['adapter'],
            'hostname' => $resources['db']['params']['host'],
            'database' => $resources['db']['params']['dbname'],
            'username' => $resources['db']['params']['username'],
            'password' => $resources['db']['params']['password'],
            'charset'  => $resources['db']['params']['charset'],
            'dsn'      => sprintf('mysql:host=%s;dbname=%s', $resources['db']['params']['host'], $resources['db']['params']['dbname']),
        ];

        return $dbConfig;
    }
89378
public static function getConfiguration(array $repositories)
	{
		$config = [[], [], []];
		foreach ($repositories as $name => $repository) {
			/** @var string $className */
			$className = is_object($repository) ? get_class($repository) : $repository;
			$config[0][$className] = true;
			$config[1][$name] = $className;
			foreach ($repository::getEntityClassNames() as $entityClassName) {
				$config[2][$entityClassName] = $className;
			}
		}
		return $config;
	}
582964
private function getRepositoryDefinition($object, array $services, ContainerBuilder $container)
    {
        $repositoryKey = $this->getContainerKey('repository', $object, '.class');

        // default repository
        $repositoryClass = 'Sulu\Component\Persistence\Repository\ORM\EntityRepository';

        if ($container->hasParameter($repositoryKey)) {
            $repositoryClass = $container->getParameter($repositoryKey);
        }

        if (isset($services['repository'])) {
            $repositoryClass = $services['repository'];
        }

        $definition = new Definition($repositoryClass);
        $definition->setArguments([
            new Reference($this->getEntityManagerServiceKey()),
            $this->getClassMetadataDefinition($services['model']),
        ]);

        return $definition;
    }
35354
public function getContainer($service = null)
    {
        return is_null($service) ? ($this->container ?: app()) : ($this->container[$service] ?: app($service));
    }
907030
public function getServiceProfile($service)
    {
        if (isset($this->serviceProfiles[$service])) {
            return $this->serviceProfiles[$service];
        }

        return null;
    }
600306
private function getDefinitionsAsArray(ContainerBuilder $container, ServiceConfig $serviceConfig)
    {
        $services = array();

        foreach ($this->findServiceIdsByTag($container, $serviceConfig) as $name => $serviceId) {
            $services[$name] = $this->getDefinitionForServiceId($serviceId, $serviceConfig);
        }

        return $services;
    }
453692
public function createService(ServiceLocatorInterface $services)
    {
        if (null !== $this->configurationKey) {
            $this->configure($this->getOptions($services, $this->configurationKey));
        }
        
        return $this;
    }
1028734
protected function getDbConfig($name)
    {
        if (empty($name)) {
            throw new InvalidArgumentException("Service 'name' can not be empty.");
        }

        return \Cache::rememberForever('service_mgr:' . $name, function () use ($name) {
            /** @var Service $service */
            if (empty($service = Service::whereName($name)->first())) {
                throw new NotFoundException("Could not find a service for $name");
            }

            $service->protectedView = false;

            return $service->toArray();
        });
    }
13920
public function load(array $configs, ContainerBuilder $container)
    {
        $configs[] = $this->options;
        $configuration = $this->getConfiguration($configs, $container);
        $config = $this->processConfiguration($configuration, $configs);

        $container->register('doctrine.orm.metadata_driver', 'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain');

        foreach ($config['mapping'] as $name => $mappingConfig) {
            $mappingConfig['name'] = $name;
            $this->configureMappingDriver($mappingConfig, $container);
        }

        $container->register('doctrine.orm.configuration', 'Doctrine\ORM\Configuration')
            ->addMethodCall('setMetadataDriverImpl', array(new Reference('doctrine.orm.metadata_driver')))
            ->addMethodCall('setProxyNamespace', array('Proxy'));

        if ($container->hasParameter('app.cache') && $container->getParameter('app.cache') === true) {
            $container->getDefinition('doctrine.orm.configuration')
                ->addMethodCall('setProxyDir', array('%app.cache_dir%/doctrine'));
        } else {
            $container->getDefinition('doctrine.orm.configuration')
                ->addMethodCall('setProxyDir', array(sys_get_temp_dir().'/doctrine'))
                ->addMethodCall('setAutoGenerateProxyClasses', array(AbstractProxyFactory::AUTOGENERATE_EVAL));

        }

        $container->register('doctrine.orm.entity_manager', 'Doctrine\ORM\EntityManager')
            ->setFactoryClass('Doctrine\ORM\EntityManager')
            ->setFactoryMethod('create')
            ->addArgument($config['database'])
            ->addArgument(new Reference('doctrine.orm.configuration'));

        $container->setAlias('doctrine.dbal.configuration', new Alias('doctrine.orm.configuration'));

        $container->register('doctrine.dbal.database_connection', 'Doctrine\DBAL\Connection')
            ->setFactoryService('doctrine.orm.entity_manager')
            ->setFactoryMethod('getConnection');
    }