Register the bundle for the application.

@param  string  $bundle
@param  array   $config
@return void
547817
public static function register($bundle, $config = array())
	{
		$defaults = array('handles' => null, 'auto' => false);

		// If the given configuration is actually a string, we will assume it is a
		// location and set the bundle name to match it. This is common for most
		// bundles that simply live in the root bundle directory.
		if (is_string($config))
		{
			$bundle = $config;

			$config = array('location' => $bundle);
		}

		// If no location is set, we will set the location to match the name of
		// the bundle. This is for bundles that are installed on the root of
		// the bundle directory so a location was not set.
		if ( ! isset($config['location']))
		{
			$config['location'] = $bundle;
		}

		static::$bundles[$bundle] = array_merge($defaults, $config);

		// It is possible for the developer to specify auto-loader mappings
		// directly on the bundle registration. This provides a convenient
		// way to register mappings without a bootstrap.
		if (isset($config['autoloads']))
		{
			static::autoloads($bundle, $config);
		}
	}
549478
private function UpdateBundleVersion($bundle)
    {
        $instBundle = InstalledBundle::Schema()->ByBundle($bundle);
        if (!$instBundle)
        {
            $instBundle = new InstalledBundle();
        }
        $instBundle->SetVersion($this->installedBundles[$bundle]);
        $instBundle->SetBundle($bundle);
        $instBundle->SetLastUpdate(Date::Now());
        $instBundle->Save();
    }
256122
public function load(array $configs, ContainerBuilder $container)
    {
        parent::load($configs, $container);

        // Only load doctrine configuration if bundle is enabled
        if (array_key_exists('DoctrineBundle', $container->getParameter('kernel.bundles'))) {
            $doctrineLoader = new ServiceLoader($container);
            $doctrineLoader->loadFiles(__DIR__.'/../Resources/config/doctrine');
        }

        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $registry = $container->getDefinition(QueryHandlerRegistry::class);
        /** @var array $configurations */
        $configurations = $config['configurations'];
        foreach ($configurations as $code => $configuration) {
            $registry->addMethodCall('addRawQueryHandlerConfiguration', [$code, $configuration]);
        }
    }
31007
@SuppressWarnings("PMD.UseVarargs")
    public void disableBundle(final Class<? extends GuiceyBundle>[] bundles) {
        for (Class<? extends GuiceyBundle> bundle : bundles) {
            registerDisable(ConfigItem.Bundle, bundle);
        }
    }
979140
public function add($section, $config = array())
    {
        if (! isset($this->config[$section])) {
            $this->config[$section] = array();
        }

        $this->config[$section] = array_merge($this->config[$section], $config);
    }
648745
public function pushBundle(string $name, string $bundle): self
    {
        if (!class_exists($bundle))
        {
            throw new Invalid('Processor ' . $bundle . ' not found');
        }

        $this->bundles[$name] = $bundle;

        return $this;
    }
842661
public function initialize(array $config)
    {
        $config += $this->_defaultConfig;
        $this->config('fields', $this->_resolveFields($config['fields']));
        $this->config('strategy', $this->_resolveStrategy($config['strategy']));
    }
28174
private function register_core_services( Config $config ) {
		$this->share( array( 'config' => 'Intraxia\Jaxion\Core\Config' ), $config );
		$this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function () {
			return new Loader;
		} );
		$this->share( array( 'i18n' => 'Intaxia\Jaxion\Contract\Core\I18n' ), function ( Container $app ) {
			return new I18n( $app->fetch( 'basename' ), $app->fetch( 'path' ) );
		} );
	}
838868
public static function register(array $config=[]) {
        $class = get_called_class();

        self::$o = new $class($config);

        Exception::register();

        self::$o->register and Pool::object(
            'nb\event\Framework',
            Config::$o->register
        );

        Pool::object('nb\event\Framework')->config(self::$o);

        self::$o->import(self::$o->path_autoinclude);

        is_file(self::$o->composer) and require self::$o->composer;
    }
954058
public static function start($bundle)
		{
			if (static::started($bundle)) {
				return;
			}

			if (!static::exists($bundle)) {
				throw new Exception("Bundle [$bundle] has not been installed.");
			}

			if (!is_null($starter = static::option($bundle, 'starter'))) {
				$starter();
			} elseif (File::exists($path = static::path($bundle) . 'start.php')) {
				require $path;
			}

			static::routes($bundle);
			static::$started[] = Inflector::lower($bundle);
		}
1157262
private function registerModule(Bundle $bundle)
    {
        $params = $this->getModule($this->rootDir.$bundle->getPath().DIRECTORY_SEPARATOR.'campaignchain.yml');

        // General installation routine.
        if (!is_array($params['modules']) || !count($params['modules'])) {
            return;
        }

        foreach ($params['modules'] as $identifier => $moduleParams) {
            $module = null;

            if ($bundle->getStatus()) {
                $status = $bundle->getStatus();
            } else {
                $status = $this->bundleConfigService->isRegisteredBundle($bundle);
            }

            /*
             * TODO: Detect whether a module has previously been registered
             * for this bundle, but the module is not anymore defined in
             * its campaignchain.yml.
             */
            if ($status == self::STATUS_REGISTERED_OLDER) {
                /** @var Module $module */
                $module = $this->em
                    ->getRepository('CampaignChainCoreBundle:Module')
                    ->findOneBy(
                        [
                            'bundle' => $bundle,
                            'identifier' => strtolower($identifier),
                        ]
                    );
            }

            switch ($bundle->getType()) {
                case 'campaignchain-channel':
                    $moduleEntity = 'ChannelModule';
                    break;
                case 'campaignchain-location':
                    $moduleEntity = 'LocationModule';
                    break;
                case 'campaignchain-campaign':
                    $moduleEntity = 'CampaignModule';
                    break;
                case 'campaignchain-milestone':
                    $moduleEntity = 'MilestoneModule';
                    break;
                case 'campaignchain-activity':
                    $moduleEntity = 'ActivityModule';
                    break;
                case 'campaignchain-operation':
                    $moduleEntity = 'OperationModule';
                    break;
                case 'campaignchain-report':
                case 'campaignchain-report-analytics':
                case 'campaignchain-report-budget':
                case 'campaignchain-report-sales':
                    $moduleEntity = 'ReportModule';
                    break;
                case 'campaignchain-security':
                    $moduleEntity = 'SecurityModule';
                    break;
            }

            if (!$module) {
                $entityClass = 'CampaignChain\\CoreBundle\\Entity\\'.$moduleEntity;
                /** @var Module $module */
                $module = new $entityClass();
                $module->setIdentifier(strtolower($identifier));
                $module->setBundle($bundle);
            }

            $module->setDisplayName($moduleParams['display_name']);

            /*
             * Tracking alias which allows the CTA tracking to match the
             * Location Identifier provided by the tracking script to a module.
             */
            if (isset($moduleParams['tracking_alias']) && strlen($moduleParams['tracking_alias'])) {
                $module->setTrackingAlias($moduleParams['tracking_alias']);
            }

            if (isset($moduleParams['description'])) {
                $module->setDescription($moduleParams['description']);
            }

            // Verify routes.
            if (in_array(
                $bundle->getType(),
                ['campaignchain-activity', 'campaignchain-channel', 'campaignchain-campaign', 'campaignchain-milestone']
            )) {
                // Throw error if no routes defined.
                if (
                    !isset($moduleParams['routes'])
                    || !is_array($moduleParams['routes'])
                    || !count($moduleParams['routes'])
                ) {
                    throw new \Exception(
                        'The module "'.$identifier
                        .'" in bundle "'.$bundle->getName().'"'
                        .' does not provide any of the required routes.'
                    );
                } else {
                    // Throw error if one or more routes are missing.
                    $hasMissingRoutes = false;
                    $missingRoutes = '';

                    foreach ($this->requiredRoutes[$bundle->getType()] as $requiredRoute) {
                        if (!array_key_exists($requiredRoute, $moduleParams['routes'])) {
                            $hasMissingRoutes = true;
                            $missingRoutes .= $requiredRoute.', ';
                        }
                    }

                    if ($hasMissingRoutes) {
                        throw new \Exception(
                            'The module "'.$identifier
                            .'" in bundle "'.$bundle->getName().'"'
                            .' must define the following route(s): '
                            .rtrim($missingRoutes, ', ').'.'
                        );
                    } else {
                        $module->setRoutes($moduleParams['routes']);
                    }
                }
            } elseif (isset($moduleParams['routes']) && is_array($moduleParams['routes']) && count(
                    $moduleParams['routes']
                )
            ) {
                $module->setRoutes($moduleParams['routes']);
            }

            if (isset($moduleParams['services']) && is_array($moduleParams['services']) && count(
                    $moduleParams['services']
                )
            ) {
                $module->setServices($moduleParams['services']);
            }
            if (isset($moduleParams['hooks']) && is_array($moduleParams['hooks']) && count($moduleParams['hooks'])) {
                // TODO: Check that there's only 1 trigger hook included.
                $module->setHooks($moduleParams['hooks']);
            }
            if (isset($moduleParams['system']) && is_array($moduleParams['system']) && count($moduleParams['system'])) {
                $this->systemParams[] = $moduleParams['system'];
            }
            // Are metrics for the reports defined?
            if (isset($moduleParams['metrics']) && is_array($moduleParams['metrics']) && count(
                    $moduleParams['metrics']
                )
            ) {
                foreach ($moduleParams['metrics'] as $metricType => $metricNames) {
                    switch ($metricType) {
                        case 'activity':
                            $metricClass = 'ReportAnalyticsActivityMetric';
                            break;
                        case 'location':
                            $metricClass = 'ReportAnalyticsLocationMetric';
                            break;
                        default:
                            throw new \Exception(
                                "Unknown metric type '".$metricType."'."
                                ."Pick 'activity' or 'location' instead."
                            );
                            break;
                    }
                    foreach ($metricNames as $metricName) {
                        $metric = $this->em->getRepository('CampaignChainCoreBundle:'.$metricClass)
                            ->findOneBy(
                                [
                                    'name' => $metricName,
                                    'bundle' => $bundle->getName(),
                                ]
                            );

                        // Does the metric already exist?
                        if ($metric) {
                            /*
                             * Throw error if bundle is new and metric
                             * has already been registered.
                             */
                            if ($status == self::STATUS_REGISTERED_NO) {
                                throw new \Exception(
                                    "Metric '".$metricName."' of type '".$metricType."'"
                                    .' already exists for bundle '.$bundle->getName().'. '
                                    .'Please define another name '
                                    .'in campaignchain.yml of '.$bundle->getName().'.'
                                );
                            }
                            // Skip if same or older version of bundle.
                            continue;
                        } else {
                            // Create new metric.
                            $metricNamespacedClass = 'CampaignChain\\CoreBundle\\Entity\\'.$metricClass;
                            $metric = new $metricNamespacedClass();
                            $metric->setName($metricName);
                            $metric->setBundle($bundle->getName());
                            $this->em->persist($metric);
                        }
                    }
                }
            }

            // Process the params specific to a module type.

            // Params that must be defined for Operation modules
            if ($bundle->getType() == 'campaignchain-operation' && !isset($moduleParams['params']['owns_location'])) {
                throw new \Exception(
                    "You must set the 'owns_location' parameter in campaignchain.yml to 'true' or 'false' for module '".$identifier."' in bundle '".$bundle->getName(
                    )."'."
                );
            }

            if (isset($moduleParams['params'])) {
                $module->setParams($moduleParams['params']);
            }

            // Add new module to new bundle.
            $reflect = new \ReflectionClass($module);
            $addModuleMethod = 'add'.$reflect->getShortName();
            $bundle->$addModuleMethod($module);

            // If a campaign module, remember the conversion to other campaign types.
            if (
                $bundle->getType() == 'campaignchain-campaign' &&
                isset($moduleParams['conversions']) &&
                is_array($moduleParams['conversions']) &&
                count($moduleParams['conversions'])
            ) {
                $this->campaignConversions[$bundle->getName()][$module->getIdentifier()] = $moduleParams['conversions'];
            }

            // If an activity or Location module, remember the related channels.
            if (
                isset($moduleParams['channels']) && is_array($moduleParams['channels']) && count($moduleParams['channels'])
            ) {
                $this->channelRelationships[$moduleEntity][$bundle->getName()][$module->getIdentifier()] = $moduleParams['channels'];
            }
        }
    }
1247521
public function registerFindables(ConfigInterface $config)
    {
        $findables = (array) $config->getKey($this->getFindablesConfigKey());
        foreach ($findables as $findableKey => $findableObject) {
            $this->findables->set($findableKey, $findableObject);
        }
    }
793813
public void setBundles(java.util.Collection<Bundle> bundles) {
        if (bundles == null) {
            this.bundles = null;
            return;
        }

        this.bundles = new java.util.ArrayList<Bundle>(bundles);
    }
1258555
public function load(array $configs, ContainerBuilder $container): void
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load('services.yml');

        // If the search bundle is active register search services.
        $bundles = $container->getParameter('kernel.bundles');
        if (isset($bundles['BkstgSearchBundle'])) {
            $loader->load('services.search.yml');
        }
        $this->configureFilesystemAdapter($container, $config);
        $this->configureCdnAdapter($container, $config);
    }
917660
protected function registerMappingTypes(Config $config)
	{
		$types = $config->getSetting('mapping_types') ?: [];
		foreach($types as $dbType => $doctrineType)
		{
			if(!Type::hasType($dbType))
			{
				Type::addType($dbType, $doctrineType);
			}
		}
	}
873598
public static function loadBundle(&$bundle)
    {
        if (sizeof($bundle->content) == 0) {
            return;
        }
        
        // check for cached, preloaded bundle
        $bundleCache = Cache::getInstance('MEMCACHE', 'APC', 'FILE_ENCODED');
        $bundleCachePath = "xqbundle/{$bundle->bundleId}";
        
        if (!DEBUG && ($bundleCache->available() && $bundleCache->hasCached($bundleCachePath))) {
            $bundle = $bundleCache->getCached($bundleCachePath);
            return;
        }
        
        // preload
        $bundle->lastModified = null;
        $bundle->files = array();
        
        $fileNames = array();
        foreach ($bundle->content as $file) {
            $preloaded = self::getBundleFileDetails($bundle, $file);
            
            $bundle->files[] = $preloaded;
            $fileNames[] = $preloaded->path;
        }
        
        $bundle->contentType = self::getBundleContentType($bundle);
        $bundle->tag = md5($bundle->lastModified . $bundle->bundleId . implode('-', $fileNames));
        
        $bundle->output = self::getBundleContent($bundle);
        
        if (!DEBUG && $bundleCache->available()) {
            $bundleCache->cache($bundleCachePath, $bundle);
        }
    }
844700
public function addBundle($bundle)
    {
        if (!isset($this->_bundles)) {
            $this->_bundles = [];
        }
        if (!is_array($bundle)) {
            $bundle = [];
        }
        if (!isset($bundle['class'])) {
            $bundle['class'] = $this->bundleClass;
        }
        $bundle = Yii::createObject($bundle);
        $this->_bundles[$bundle->id] = $bundle;

        return $bundle;
    }