Gets the directory for a definition type.

@param   string              $type
@param   array               $driverConfig
@param   ContainerBuilder    $container
@return  string
508368
private function getDefinitionDir($type, array $driverConfig, ContainerBuilder $container)
    {
        $defaultDir = sprintf('%s/Resources/As3ModlrBundle', $container->getParameter('kernel.root_dir'));

        $folder = sprintf('%ss', $type);
        $key = sprintf('%s_dir', $type);

        return isset($driverConfig['parameters'][$key])
            ? Utility::locateResource($driverConfig['parameters'][$key], $container)
            : sprintf('%s/%s', $defaultDir, $folder)
        ;
    }
182214
private function configureGeolocators($config, $container)
    {
        $geolocatorName = $config['geolocator'];
        $container->setParameter('sulu_location.geolocator.name', $geolocatorName);

        $nominatim = function($config, $container) {
            $endpoint = $config['geolocators']['nominatim']['endpoint'];
            $container->setParameter('sulu_location.geolocator.service.nominatim.endpoint', $endpoint);
        };

        $google = function($config, $container) {
            $apiKey = $config['geolocators']['google']['api_key'];
            $container->setParameter('sulu_location.geolocator.service.google.api_key', $apiKey);
        };

        $nominatim($config, $container);
        $google($config, $container);
    }
254680
private function loadDrivers(ContainerBuilder $container, array $driverConfigs)
    {
        foreach ($this->drivers as $driverKey => $driver) {
            $driver->load($container, $driverConfigs[$driverKey]);
        }

        return $this->drivers;
    }
49255
public function getFileLoader(ContainerBuilder $container)
    {
        if (!$this->loader) {
            $this->loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../../Resources/config'));
        }

        return $this->loader;
    }
517789
private function resolveMappingPaths(array $config, ContainerBuilder $container)
    {
        $paths = [];

        if ($config['auto']['enabled']) {
            $bundles = $container->getParameter('kernel.bundles');

            foreach ($bundles as $bundle) {
                $bundlePath = dirname((new \ReflectionClass($bundle))->getFileName());

                foreach ($config['auto']['paths'] as $relativePath) {
                    $path = $bundlePath.'/'.$relativePath;

                    if (file_exists($path)) {
                        $paths[] = $path;
                    }
                }
            }
        }

        return array_merge($paths, $config['paths']);
    }
647456
public function configureTemplates(ContainerBuilder $container, array $config)
    {
        $templateManager = $container->getDefinition('sonata.page.template_manager');

        // add all templates to manager
        $definitions = [];
        foreach ($config['templates'] as $code => $info) {
            $definition = new Definition(Template::class, [
                $info['name'],
                $info['path'],
                $info['containers'],
            ]);

            $definition->setPublic(false);
            $definitions[$code] = $definition;
        }

        $templateManager->addMethodCall('setAll', [$definitions]);

        // set default template
        $templateManager->addMethodCall('setDefaultTemplateCode', [$config['default_template']]);
    }
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;
    }
835678
protected static function _getFiles(&$config, $type, $silent = false) {
		$typeNS = $config ["mvcNS"] [$type];
		$typeDir = \ROOT . \DS . str_replace ( "\\", \DS, $typeNS );
		if (! $silent)
			echo \ucfirst ( $type ) . " directory is " . \ROOT . $typeNS . "\n";
		return UFileSystem::glob_recursive ( $typeDir . \DS . '*' );
	}
227420
public function getService($driver)
    {
        if ($driver = explode(':', $driver) and
            isset($driver[0]) and
            $driver = explode('.', $driver[0]) and
            isset($driver[1])
        ) {
            return $this->container->get($driver[0] . '.' . $driver[1] . '_bundle.manager.' . $driver[1] . '_manager');
        }
    }
948929
public function getDriver(Container $config)
        {
            $connObject = new Configuration();
            $config = $config->assoc();

            // We map our config options to Doctrine's naming of them
            $connParamsMap = array(
                'database' => 'dbname',
                'username' => 'user',
                'hostname' => 'host',
                'pass'     => 'password'
            );

            foreach ($connParamsMap as $key => $param) {
                if (isset($config[$key])) {
                    $config[$param] = $config[$key];
                    unset($config[$key]);
                }
            }

            $type = isAke($config, 'type', 'pdo_mysql');

            $config['driver'] = $type;
            unset($config['type']);

            return DriverManager::getConnection($config, $connObject);
        }
1292612
protected function getDefinitionFile($type, $name)
    {
        if (array_key_exists($name, $this->definitionFiles)) {
            return $this->definitionFiles[$name];
        }

        $this->definitionFiles[$name] = null;
        $this->definitionFiles[$name] = $this->findDefinitionFileByComposer($name);

        if (null !== $this->definitionFiles[$name]) {
            return $this->definitionFiles[$name];
        }

        $this->definitionFiles[$name] = $this->findDefinitionFileByName($name);

        if (null !== $this->definitionFiles[$name]) {
            return $this->definitionFiles[$name];
        }

        $this->definitionFiles[$name] = $this->findDefinitionFileByRegex($type, $name);

        return $this->definitionFiles[$name];
    }
116605
protected function setupWpcliDriver(FileLoader $loader, ContainerBuilder $container, array $config)
    {
        if (! isset($config['wpcli'])) {
            return;
        }

        $loader->load('drivers/wpcli.yml');

        $config['wpcli']['alias'] = isset($config['wpcli']['alias']) ? $config['wpcli']['alias'] : '';
        $container->setParameter('wordpress.driver.wpcli.alias', $config['wpcli']['alias']);

        $config['wpcli']['path'] = isset($config['path']) ? $config['path'] : '';
        $container->setParameter('wordpress.driver.wpcli.path', $config['path']);

        $config['wpcli']['binary'] = isset($config['wpcli']['binary']) ? $config['wpcli']['binary'] : null;
        $container->setParameter('wordpress.driver.wpcli.binary', $config['wpcli']['binary']);
    }
782386
public function createDriver($driver, array $config = [])
    {
        $driver = strtolower($driver);

        $queueConfig = new Structure($config);

        if (!$queueConfig->toArray()) {
            throw new \LogicException('No queue config for ' . $driver);
        }

        // TODO: All driver should have DI pattern.
        switch ($driver) {
            case 'sqs':
                return new SqsQueueDriver(
                    $queueConfig->get('key'),
                    $queueConfig->get('secret'),
                    $queueConfig->get('queue', 'default'),
                    [
                        'region' => $queueConfig->get('region', 'us-west-2'),
                        'version' => $queueConfig->get('version', 'latest'),
                    ]
                );

            case 'sync':
                return new SyncQueueDriver();

            case 'database':
                return new DatabaseQueueDriver(
                    $this->container->get('db'),
                    $queueConfig->get('queue', 'default'),
                    $queueConfig->get('table', 'queue_jobs')
                );

            case 'pdo':
                return new PdoQueueDriver(
                    $this->container->get('db')->getConnection(),
                    $queueConfig->get('queue', 'default'),
                    $queueConfig->get('table', 'queue_jobs')
                );

            case 'ironmq':
                return new IronmqQueueDriver(
                    $queueConfig->get('project_id'),
                    $queueConfig->get('token'),
                    $queueConfig->get('queue', 'default'),
                    [
                        'host' => $queueConfig->get('region', 'mq-aws-us-east-1-1') . '.iron.io',
                    ]
                );

            case 'rabbitmq':
                return new RabbitmqQueueDriver(
                    $queueConfig->get('queue', 'default'),
                    (array) $queueConfig->toArray()
                );

            case 'resque':
                return new ResqueQueueDriver(
                    $queueConfig->get('host', 'localhost'),
                    $queueConfig->get('port', '6379'),
                    $queueConfig->get('queue', 'default')
                );

            case 'beanstalkd':
                return new BeanstalkdQueueDriver(
                    $queueConfig->get('host', '127.0.0.1'),
                    $queueConfig->get('queue', 'default'),
                    $queueConfig->get('timeout', 60)
                );

            default:
                return new NullQueueDriver();
        }
    }
681181
private static function getDirectories(ContainerBuilder $container): array
    {
        /**
         * @noinspection PhpUnhandledExceptionInspection
         * @psalm-var    array<int, string> $directories
         *
         * @var string[] $directories
         */
        $directories = true === $container->hasParameter('service_bus.auto_import.handlers_directories')
            ? $container->getParameter('service_bus.auto_import.handlers_directories')
            : [];

        return $directories;
    }
96356
public function configureCdnAdapter(ContainerBuilder $container, array $config)
    {
        // add the default configuration for the server cdn
        if ($container->hasDefinition('sonata.media.cdn.server') && isset($config['cdn']['server'])) {
            $container->getDefinition('sonata.media.cdn.server')
                ->replaceArgument(0, $config['cdn']['server']['path'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.server');
        }

        if ($container->hasDefinition('sonata.media.cdn.panther') && isset($config['cdn']['panther'])) {
            $container->getDefinition('sonata.media.cdn.panther')
                ->replaceArgument(0, $config['cdn']['panther']['path'])
                ->replaceArgument(1, $config['cdn']['panther']['username'])
                ->replaceArgument(2, $config['cdn']['panther']['password'])
                ->replaceArgument(3, $config['cdn']['panther']['site_id'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.panther');
        }

        if ($container->hasDefinition('sonata.media.cdn.cloudfront') && isset($config['cdn']['cloudfront'])) {
            $container->getDefinition('sonata.media.cdn.cloudfront')
                ->replaceArgument(0, $config['cdn']['cloudfront']['path'])
                ->replaceArgument(1, $config['cdn']['cloudfront']['key'])
                ->replaceArgument(2, $config['cdn']['cloudfront']['secret'])
                ->replaceArgument(3, $config['cdn']['cloudfront']['distribution_id'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.cloudfront');
        }

        if ($container->hasDefinition('sonata.media.cdn.fallback') && isset($config['cdn']['fallback'])) {
            $container->getDefinition('sonata.media.cdn.fallback')
                ->replaceArgument(0, new Reference($config['cdn']['fallback']['master']))
                ->replaceArgument(1, new Reference($config['cdn']['fallback']['fallback']))
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.fallback');
        }
    }
1291658
public function configureMultisite(ContainerBuilder $container, array $config)
    {
        $multisite = $config['multisite'];

        if ('host' === $multisite) {
            $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host');

            $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            $container->removeDefinition('sonata.page.site.selector.host_with_path');
            $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
        } elseif ('host_by_locale' === $multisite) {
            $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_by_locale');

            $container->removeDefinition('sonata.page.site.selector.host');
            $container->removeDefinition('sonata.page.site.selector.host_with_path');
            $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
        } else {
            /*
             * The multipath option required a specific router and RequestContext
             */
            $container->setAlias('router.request_context', 'sonata.page.router.request_context');

            if ('host_with_path' === $multisite) {
                $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_with_path');

                $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
                $container->removeDefinition('sonata.page.site.selector.host');
                $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            } elseif ('host_with_path_by_locale' === $multisite) {
                $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_with_path_by_locale');

                $container->removeDefinition('sonata.page.site.selector.host_with_path');
                $container->removeDefinition('sonata.page.site.selector.host');
                $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            }
        }

        if ($container->hasAlias('sonata.page.site.selector')) {
            $container->getAlias('sonata.page.site.selector')->setPublic(true);
        }
    }
985771
public function loadInternal(array $config, ContainerBuilder $container)
    {
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load('services.yml');

        $bundles = $container->getParameter('kernel.bundles');

        $directories = [];
        if ($config['metadata']['auto_detection']) {
            foreach ($bundles as $name => $class) {
                $ref                                   = new \ReflectionClass($class);
                $directories[$ref->getNamespaceName()] = dirname($ref->getFileName()) . '/Resources/config/fixture';
            }
        }

        foreach ($config['metadata']['directories'] as $directory) {
            $directory['path'] = rtrim(str_replace('\\', '/', $directory['path']), '/');
            if ('@' === $directory['path'][0]) {
                preg_match('~^@([a-z0-9_]+)~i', $directory['path'], $match);

                if (isset($match[1])) {
                    list($prefixedBundleName, $bundleName) = $match;
                    if (!isset($bundles[$bundleName])) {
                        throw new RuntimeException(sprintf('The bundle "%s" has not been registered with AppKernel. Available bundles: %s', $bundleName, implode(', ', array_keys($bundles))));
                    }
                    $ref = new \ReflectionClass($bundles[$bundleName]);
                    $directory['path'] = dirname($ref->getFileName()).substr($directory['path'], strlen($prefixedBundleName));
                }
            }
            $directories[rtrim($directory['namespace_prefix'], '\\')] = rtrim($directory['path'], '\\/');
        }

        $container
            ->getDefinition('trappar_alice_generator.metadata.file_locator')
            ->addArgument($directories);

        $container
            ->getDefinition(YamlWriter::class)
            ->addArgument($config['yaml']['inline'])
            ->addArgument($config['yaml']['indent']);

        $container
            ->getDefinition(ValueVisitor::class)
            ->addArgument($config['strictTypeChecking']);
    }