Extracts and returns bundle loader recipes from Config.

@param Config $config

@return array|null
177580
private function getLoaderRecipesByConfig(Config $config)
    {
        $recipes = null;
        $bundleConfig = $config->getBundleConfig();
        if (null !== $bundleConfig && isset($bundleConfig['bundle_loader_recipes'])) {
            $recipes = $bundleConfig['bundle_loader_recipes'];
        }

        return $recipes;
    }
1041946
public function config($config)
    {
        if (is_array($config)) {
            $this->config = array_merge($this->config, $config);
        } elseif (isset($this->config[$config])) {
            return $this->config[$config];
        } else {
            return;
        }
    }
226298
private function loadFullBundles()
    {
        $data = [];
        foreach ($this->bundlesBaseDir as $serviceId => $baseDir) {
            $config = $this->loadAndGetBundleConfigByBaseDir($serviceId, $baseDir);
            $bundleConfig = $config->getSection('bundle');
            if (isset($bundleConfig['enable']) && !((boolean) $bundleConfig['enable'])) {
                continue;
            }

            $recipes = $this->getLoaderRecipesByConfig($config);

            $data[] = [$config, $recipes];

            $this->loadServices($config, $serviceId, $this->getCallbackFromRecipes(self::SERVICE_RECIPE_KEY, $recipes));
        }

        foreach ($data as $row) {
            list($config, $recipes) = $row;

            $this->loadEvents($config, $this->getCallbackFromRecipes(self::EVENT_RECIPE_KEY, $recipes));
            $this->loadRoutes($config, $this->getCallbackFromRecipes(self::ROUTE_RECIPE_KEY, $recipes));
            $this->addClassContentDir($config, $this->getCallbackFromRecipes(self::CLASSCONTENT_RECIPE_KEY, $recipes));
            $this->addTemplatesDir($config, $this->getCallbackFromRecipes(self::TEMPLATE_RECIPE_KEY, $recipes));
            $this->addHelpersDir($config, $this->getCallbackFromRecipes(self::HELPER_RECIPE_KEY, $recipes));
            $this->addResourcesDir($config, $this->getCallbackFromRecipes(self::RESOURCE_RECIPE_KEY, $recipes));
            $this->addNamespaces($config, $this->getCallbackFromRecipes(self::NAMESPACE_RECIPE_KEY, $recipes));
            $this->runRecipe($config, $this->getCallbackFromRecipes(self::CUSTOM_RECIPE_KEY, $recipes));
        }
    }
218296
public function getBundleMapping($name, $config = [])
    {
        if (!is_string($name)) {
            throw new \LogicException('getBundleMapping() in the Metadata collector expects a string argument only!');
        }

        $cacheName =  'ongr.metadata.mapping.' . md5($name.serialize($config));

        $this->enableCache && $mappings = $this->cache->fetch($cacheName);

        if (isset($mappings) && false !== $mappings) {
            return $mappings;
        }

        $mappings = [];
        $documentDir = isset($config['document_dir']) ? $config['document_dir'] : $this->finder->getDocumentDir();

        // Handle the case when single document mapping requested
        // Usage od ":" in name is deprecated. This if is only for BC.
        if (strpos($name, ':') !== false) {
            list($bundle, $documentClass) = explode(':', $name);
            $documents = $this->finder->getBundleDocumentClasses($bundle);
            $documents = in_array($documentClass, $documents) ? [$documentClass] : [];
        } else {
            $documents = $this->finder->getBundleDocumentClasses($name, $documentDir);
            $bundle = $name;
        }

        $bundleNamespace = $this->finder->getBundleClass($bundle);
        $bundleNamespace = substr($bundleNamespace, 0, strrpos($bundleNamespace, '\\'));

        if (!count($documents)) {
            return [];
        }

        // Loop through documents found in bundle.
        foreach ($documents as $document) {
            $documentReflection = new \ReflectionClass(
                $bundleNamespace .
                '\\' . str_replace('/', '\\', $documentDir) .
                '\\' . $document
            );

            try {
                $documentMapping = $this->getDocumentReflectionMapping($documentReflection);
                if (!$documentMapping) {
                    continue;
                }
            } catch (MissingDocumentAnnotationException $exception) {
                // Not a document, just ignore
                continue;
            }

            if (!array_key_exists($documentMapping['type'], $mappings)) {
                $documentMapping['bundle'] = $bundle;
                $mappings = array_merge($mappings, [$documentMapping['type'] => $documentMapping]);
            } else {
                throw new \LogicException(
                    $bundle . ' has 2 same type names defined in the documents. ' .
                    'Type names must be unique!'
                );
            }
        }

        $this->enableCache && $this->cache->save($cacheName, $mappings);

        return $mappings;
    }
1090951
protected function parseConfig($config)
    {
        $parsed = [];

        foreach ($config as $key=>$value) {
            if ($value instanceof XType) {
                $parsed[$key] = $value;
                continue;
            }
            $parsed[$key] = $this->stringToType($value);
        }

        return $parsed;
    }
373166
protected function getPluginProcessors(array $config)
    {
        $processors = isset($config['pluginProcessors'])
            ? $config['pluginProcessors']
            : $this->getDefaultPluginProcessors();

        if (!is_array($processors)) {
            throw new \RuntimeException('Configuration "pluginProcessors" key must reference an array');
        }

        if (!empty($processors)) {
            $invalid = array_filter(
                $processors,
                function ($processor) {
                    return !$processor instanceof PluginProcessorInterface;
                }
            );
            if (!empty($invalid)) {
                throw new \RuntimeException(
                    'All configuration "pluginProcessors" array values must implement'
                        . ' \Phergie\Irc\Bot\React\PluginProcessor\PluginProcessorInterface'
                );
            }
        }

        return $processors;
    }
1096661
public function config($config = null)
    {
        if ($this->_config) {
            return $this->_config;
        }
        $this->_config = $config;
        return $this->_config;
    }
334052
public function getParser(array $config = null)
	{
		$this->configOptimizer->reset();

		// Get the stylesheet used for rendering
		$xslt      = new XSLT;
		$xslt->optimizer->normalizer->remove('RemoveLivePreviewAttributes');
		$this->xsl = $xslt->getXSL($this->configurator->rendering);

		// Prepare the parser's config
		$this->config = (isset($config)) ? $config : $this->configurator->asConfig();
		$this->config = ConfigHelper::filterConfig($this->config, 'JS');
		$this->config = $this->callbackGenerator->replaceCallbacks($this->config);

		// Get the parser's source and inject its config
		$src = $this->getHints() . $this->injectConfig($this->getSource());

		// Export the public API
		$src .= "if (!window['s9e']) window['s9e'] = {};\n" . $this->getExports();

		// Minify the source
		$src = $this->getMinifier()->get($src);

		// Wrap the source in a function to protect the global scope
		$src = '(function(){' . $src . '})()';

		return $src;
	}
1117126
protected function getConfig($config = []): ConfigInterface
    {
        $defaults = ConfigFactory::create(dirname(__DIR__, 2) . '/config/defaults.php', $config);
        $config   = $config
            ? ConfigFactory::createFromArray(array_merge_recursive($defaults->getArrayCopy(), $config->getArrayCopy()))
            : $defaults;

        return $config->getSubConfig('BrightNucleus\View');
    }
886030
private function loadServices(Config $config, $serviceId, callable $recipe = null)
    {
        if (false === $this->runRecipe($config, $recipe)) {
            $directories = array_unique(array_merge(
                            BundleConfigDirectory::getDirectories(
                                    $this->application->getBaseRepository(),
                                    $this->application->getContext(),
                                    $this->application->getEnvironment(),
                                    str_replace('bundle.', '', $serviceId)
                            ), BundleConfigDirectory::getDirectories(
                                    $this->application->getBaseRepository(),
                                    $this->application->getContext(),
                                    $this->application->getEnvironment(),
                                    basename(dirname($config->getBaseDir()))
            )));
            array_unshift($directories, $this->getConfigDirByBundleBaseDir(dirname($config->getBaseDir())));

            foreach ($directories as $directory) {
                $filepath = $directory.DIRECTORY_SEPARATOR.'services.xml';
                if (is_file($filepath) && is_readable($filepath)) {
                    try {
                        ServiceLoader::loadServicesFromXmlFile($this->container, $directory);
                    } catch (\Exception $e) {
                        // nothing to do
                    }
                }

                $filepath = $directory.DIRECTORY_SEPARATOR.'services.yml';
                if (is_file($filepath) && is_readable($filepath)) {
                    try {
                        ServiceLoader::loadServicesFromYamlFile($this->container, $directory);
                    } catch (\Exception $e) {
                        // nothing to do
                    }
                }
            }
        }
    }
791956
protected static function autoloads($bundle, $config)
	{
		$path = rtrim(Bundle::path($bundle), DS);

		foreach ($config['autoloads'] as $type => $mappings)
		{
			// When registering each type of mapping we'll replace the (:bundle)
			// place-holder with the path to the bundle's root directory, so
			// the developer may dryly register the mappings.
			$mappings = array_map(function($mapping) use ($path)
			{
				return str_replace('(:bundle)', $path, $mapping);

			}, $mappings);

			// Once the mappings are formatted, we will call the Autoloader
			// function matching the mapping type and pass in the array of
			// mappings so they can be registered and used.
			Autoloader::$type($mappings);
		}
	}
493691
protected function getGauges($config)
    {
        if (null === $this->gauges) {
            $this->gauges = array();

            foreach ($config as $path => $details) {
                $className = $details['class'];
                if (class_exists($className)) {
                    $reflection = new \ReflectionClass($className);

                    if ($reflection->getConstructor()) {
                        $this->gauges[$path] = $reflection->newInstanceArgs(
                            $details['arguments'] ? $details['arguments'] : array());
                    }
                    else {
                        $this->gauges[$path] = $reflection->newInstance();
                    }
                }
                else {
                    throw new \RuntimeException(sprintf(
                        'Class does not exists %s'
                    ), $className);
                }
            }

            if (empty($this->gauges)) {
                throw new \RuntimeException(
                    sprintf('No gauges found for provided string %s', $input->getArgument('gauges-class'))
                );
            }
        }

        return $this->gauges;
    }
808380
private function getAllFiles(Config $config)
    {
        $file_extensions = $config->getFileExtensions();
        $file_paths = [];

        foreach ($config->getProjectDirectories() as $dir_name) {
            $file_paths = array_merge(
                $file_paths,
                $this->file_provider->getFilesInDir($dir_name, $file_extensions)
            );
        }

        return $file_paths;
    }
149916
private function massageConfig(array $config, string $configPath) : array
    {
        if (!isset($config['installed_paths'])) {
            return $config;
        }

        $config['installed_paths'] = implode(',', array_map(function ($path) use ($configPath) {
            return dirname($configPath) . '/' . $path;
        }, explode(',', $config['installed_paths'])));

        return $config;
    }
1298339
protected function getSSLBuilder($config)
    {
        if (empty($config)) {
            return null;
        }

        $ssl = \Cassandra::ssl();
        $serverCert = array_get($config, 'server_cert_path');
        $clientCert = array_get($config, 'client_cert_path');
        $privateKey = array_get($config, 'private_key_path');
        $passPhrase = array_get($config, 'key_pass_phrase');

        if (!empty($serverCert) && !empty($clientCert)) {
            if (empty($privateKey)) {
                throw new InternalServerErrorException('No private key provider.');
            }

            return $ssl->withVerifyFlags(\Cassandra::VERIFY_PEER_CERT)
                ->withTrustedCerts($serverCert)
                ->withClientCert($clientCert)
                ->withPrivateKey($privateKey, $passPhrase)
                ->build();
        } elseif (!empty($serverCert)) {
            return $ssl->withVerifyFlags(\Cassandra::VERIFY_PEER_CERT)
                ->withTrustedCerts(getenv('SERVER_CERT'))
                ->build();
        } elseif (true === boolval(array_get($config, 'ssl', array_get($config, 'tls', false)))) {
            return $ssl->withVerifyFlags(\Cassandra::VERIFY_NONE)
                ->build();
        } else {
            return null;
        }
    }
1220424
public function getRequiredFiles($config)
    {
        $files = [];
        
        foreach ($config as $key => $name) {
            
            if (is_numeric($key) && is_string($name)) {
                
                $files[] = $name;
                
            } elseif (is_numeric($key) && is_array($name)) {
                
                foreach ($name as $module => $file) {
                    $files[] = sprintf('%s: %s', $module, $file);
                }
                
            } elseif (!is_numeric($key) && is_array($name)) {
                
                foreach ($name as $file) {
                    $files[] = sprintf('%s: %s', $key, $file);
                }
                
            }
            
        }
        
        return $files;
    }
291953
public function config($config = null)
    {
        if (is_array($config)) {
            $this->_config = $config;
        } elseif (is_string($config)) {
            if (!empty($this->_config[$config])) {
                return $this->_config[$config];
            }

            return false;
        }

        return $this->_config;
    }