Registers services on the given container.

This method should only be used to configure services and parameters.
It should not get services.

@param Container $container A container instance.
@return void
487527
public function register(Container $container)
    {
        /** @var string The default route controller for templates. */
        $container['route/controller/script/class'] = ScriptRoute::class;

        $this->registerScriptFactory($container);
        $this->registerClimate($container);
    }
951766
protected function registerServiceProviders( $service_providers, Container $container ) {
		foreach ( $service_providers as $provider ) {
			$provider->register( $container );
		}
	}
800206
public function register(Container $container)
    {
        // Ensure dependencies are set
        $container->register(new EmailServiceProvider());
        $container->register(new UiServiceProvider());
        $container->register(new AssetsManagerServiceProvider());

        $this->registerAdminServices($container);
        $this->registerFactoryServices($container);
        $this->registerElfinderServices($container);
        $this->registerSelectizeServices($container);
        $this->registerMetadataExtensions($container);
        $this->registerAuthExtensions($container);
        $this->registerViewExtensions($container);
        $this->registerAssetsManager($container);

        // Register Access-Control-List (acl)
        $container->register(new AclServiceProvider());
    }
646822
public function register(Container $container, $alias = null)
    {
        $container->set('Repository', [$this, 'createRepositoryFactory'], true, true);

        if (!empty($alias)) {
            $container->alias($alias, 'Repository');
        }
    }
335003
public function register(\Pimple\Container $container)
    {
        $this->define();
        foreach ($this->hooks as $hookName => $hookDef) {
            $hook = $container["newHook.factory"];
            $hook->create($hookName, $hookDef);
            $container["hooks.service"]->addHook($hook);
        }
    }
769865
public function register(Container $container)
    {
        $container->share(\Swift_Mailer::class, [$this, 'swiftmailer'])
            ->alias('swiftmailer', \Swift_Mailer::class);

        $container->bindShared(MailerAdapterInterface::class, SwiftMailerAdapter::class)
            ->alias('mailer.adapter.swiftmailer', SwiftMailerAdapter::class);
    }
153350
public function register(Container $container)
    {
        $container['escaper'] = function (Container $c) {
            return new Escaper($c['aura.html.escaper'], $c['options']['default_charset']);
        };
        $container['command'] = function (Container $c) {
            return new Command($c['escaper'], $c['options']['autoescape']);
        };
        $container['events'] = function () {
            return new Events();
        };
    }
37192
public function register(Container $container)
    {
        $container->prepareSharedObject(AssetManager::class);
        $container->prepareSharedObject(ScriptManager::class);

        AbstractScript::$instance = function () use ($container) {
            return $container->get(ScriptManager::class);
        };
    }
840055
private function registerService(ContainerBuilder $container, $serviceId, $serviceClass)
    {
        if (class_exists($serviceClass)) {
            $container->register($serviceId, $serviceClass);
        }
    }
793634
public function register( Container $container ) {
		$this->container = $container;

		$this->container->define( array( 'router' => 'Intraxia\Jaxion\Http\Router' ), $router = new Router );

		$this->add_routes( $router );
	}
663571
public function register(Container $container)
    {
        foreach ($this->getOrmDefaults() as $key => $value) {
            if (!isset($container[$key])) {
                $container[$key] = $value;
            }
        }

        $container['orm.em.default_options'] = array(
            'connection' => 'default',
            'mappings' => array(),
            'types' => array()
        );

        $container['orm.ems.options.initializer'] = $container->protect(function () use ($container) {
            static $initialized = false;

            if ($initialized) {
                return;
            }

            $initialized = true;

            if (!isset($container['orm.ems.options'])) {
                $container['orm.ems.options'] = array('default' => isset($container['orm.em.options']) ? $container['orm.em.options'] : array());
            }

            $tmp = $container['orm.ems.options'];
            foreach ($tmp as $name => &$options) {
                $options = array_replace($container['orm.em.default_options'], $options);

                if (!isset($container['orm.ems.default'])) {
                    $container['orm.ems.default'] = $name;
                }
            }
            $container['orm.ems.options'] = $tmp;
        });

        $container['orm.em_name_from_param_key'] = $container->protect(function ($paramKey) use ($container) {
            $container['orm.ems.options.initializer']();

            if (isset($container[$paramKey])) {
                return $container[$paramKey];
            }

            return $container['orm.ems.default'];
        });

        $container['orm.ems'] = function ($container) {
            $container['orm.ems.options.initializer']();

            $ems = new Container();
            foreach ($container['orm.ems.options'] as $name => $options) {
                if ($container['orm.ems.default'] === $name) {
                    // we use shortcuts here in case the default has been overridden
                    $config = $container['orm.em.config'];
                } else {
                    $config = $container['orm.ems.config'][$name];
                }

                $ems[$name] = function ($ems) use ($container, $options, $config) {
                    return EntityManager::create(
                        $container['dbs'][$options['connection']],
                        $config,
                        $container['dbs.event_manager'][$options['connection']]
                    );
                };
            }

            return $ems;
        };

        $container['orm.ems.config'] = function ($container) {
            $container['orm.ems.options.initializer']();

            $configs = new Container();
            foreach ($container['orm.ems.options'] as $name => $options) {
                $config = new Configuration;

                $container['orm.cache.configurer']($name, $config, $options);

                $config->setProxyDir($container['orm.proxies_dir']);
                $config->setProxyNamespace($container['orm.proxies_namespace']);
                $config->setAutoGenerateProxyClasses($container['orm.auto_generate_proxies']);

                $config->setCustomStringFunctions($container['orm.custom.functions.string']);
                $config->setCustomNumericFunctions($container['orm.custom.functions.numeric']);
                $config->setCustomDatetimeFunctions($container['orm.custom.functions.datetime']);
                $config->setCustomHydrationModes($container['orm.custom.hydration_modes']);

                $config->setClassMetadataFactoryName($container['orm.class_metadata_factory_name']);
                $config->setDefaultRepositoryClassName($container['orm.default_repository_class']);

                $config->setEntityListenerResolver($container['orm.entity_listener_resolver']);
                $config->setRepositoryFactory($container['orm.repository_factory']);

                $config->setNamingStrategy($container['orm.strategy.naming']);
                $config->setQuoteStrategy($container['orm.strategy.quote']);

                $chain = $container['orm.mapping_driver_chain.locator']($name);

                foreach ((array) $options['mappings'] as $entity) {
                    if (!is_array($entity)) {
                        throw new \InvalidArgumentException(
                            "The 'orm.em.options' option 'mappings' should be an array of arrays."
                        );
                    }

                    if (isset($entity['alias'])) {
                        $config->addEntityNamespace($entity['alias'], $entity['namespace']);
                    }

                    switch ($entity['type']) {
                        case 'annotation':
                            $useSimpleAnnotationReader =
                                isset($entity['use_simple_annotation_reader'])
                                ? $entity['use_simple_annotation_reader']
                                : true;
                            $driver = $config->newDefaultAnnotationDriver((array) $entity['path'], $useSimpleAnnotationReader);
                            $chain->addDriver($driver, $entity['namespace']);
                            break;
                        case 'yml':
                            $driver = new YamlDriver($entity['path']);
                            $chain->addDriver($driver, $entity['namespace']);
                            break;
                        case 'simple_yml':
                            $driver = new SimplifiedYamlDriver(array($entity['path'] => $entity['namespace']));
                            $chain->addDriver($driver, $entity['namespace']);
                            break;
                        case 'xml':
                            $driver = new XmlDriver($entity['path']);
                            $chain->addDriver($driver, $entity['namespace']);
                            break;
                        case 'simple_xml':
                            $driver = new SimplifiedXmlDriver(array($entity['path'] => $entity['namespace']));
                            $chain->addDriver($driver, $entity['namespace']);
                            break;
                        case 'php':
                            $driver = new StaticPHPDriver($entity['path']);
                            $chain->addDriver($driver, $entity['namespace']);
                            break;
                        default:
                            throw new \InvalidArgumentException(sprintf('"%s" is not a recognized driver', $entity['type']));
                            break;
                    }
                }
                $config->setMetadataDriverImpl($chain);

                foreach ((array) $options['types'] as $typeName => $typeClass) {
                    if (Type::hasType($typeName)) {
                        Type::overrideType($typeName, $typeClass);
                    } else {
                        Type::addType($typeName, $typeClass);
                    }
                }

                $configs[$name] = $config;
            }

            return $configs;
        };

        $container['orm.cache.configurer'] = $container->protect(function ($name, Configuration $config, $options) use ($container) {
            $config->setMetadataCacheImpl($container['orm.cache.locator']($name, 'metadata', $options));
            $config->setQueryCacheImpl($container['orm.cache.locator']($name, 'query', $options));
            $config->setResultCacheImpl($container['orm.cache.locator']($name, 'result', $options));
            $config->setHydrationCacheImpl($container['orm.cache.locator']($name, 'hydration', $options));
        });

        $container['orm.cache.locator'] = $container->protect(function ($name, $cacheName, $options) use ($container) {
            $cacheNameKey = $cacheName . '_cache';

            if (!isset($options[$cacheNameKey])) {
                $options[$cacheNameKey] = $container['orm.default_cache'];
            }

            if (isset($options[$cacheNameKey]) && !is_array($options[$cacheNameKey])) {
                $options[$cacheNameKey] = array(
                    'driver' => $options[$cacheNameKey],
                );
            }

            if (!isset($options[$cacheNameKey]['driver'])) {
                throw new \RuntimeException("No driver specified for '$cacheName'");
            }

            $driver = $options[$cacheNameKey]['driver'];

            $cacheInstanceKey = 'orm.cache.instances.'.$name.'.'.$cacheName;
            if (isset($container[$cacheInstanceKey])) {
                return $container[$cacheInstanceKey];
            }

            $cache = $container['orm.cache.factory']($driver, $options[$cacheNameKey]);

            if (isset($options['cache_namespace']) && $cache instanceof CacheProvider) {
                $cache->setNamespace($options['cache_namespace']);
            }

            return $container[$cacheInstanceKey] = $cache;
        });

        $container['orm.cache.factory.backing_memcache'] = $container->protect(function () {
            return new \Memcache;
        });

        $container['orm.cache.factory.memcache'] = $container->protect(function ($cacheOptions) use ($container) {
            if (empty($cacheOptions['host']) || empty($cacheOptions['port'])) {
                throw new \RuntimeException('Host and port options need to be specified for memcache cache');
            }

            /** @var \Memcache $memcache */
            $memcache = $container['orm.cache.factory.backing_memcache']();
            $memcache->connect($cacheOptions['host'], $cacheOptions['port']);

            $cache = new MemcacheCache;
            $cache->setMemcache($memcache);

            return $cache;
        });

        $container['orm.cache.factory.backing_memcached'] = $container->protect(function () {
            return new \Memcached;
        });

        $container['orm.cache.factory.memcached'] = $container->protect(function ($cacheOptions) use ($container) {
            if (empty($cacheOptions['host']) || empty($cacheOptions['port'])) {
                throw new \RuntimeException('Host and port options need to be specified for memcached cache');
            }

            /** @var \Memcached $memcached */
            $memcached = $container['orm.cache.factory.backing_memcached']();
            $memcached->addServer($cacheOptions['host'], $cacheOptions['port']);

            $cache = new MemcachedCache;
            $cache->setMemcached($memcached);

            return $cache;
        });

        $container['orm.cache.factory.backing_redis'] = $container->protect(function () {
            return new \Redis;
        });

        $container['orm.cache.factory.redis'] = $container->protect(function ($cacheOptions) use ($container) {
            if (empty($cacheOptions['host']) || empty($cacheOptions['port'])) {
                throw new \RuntimeException('Host and port options need to be specified for redis cache');
            }

            /** @var \Redis $redis */
            $redis = $container['orm.cache.factory.backing_redis']();
            $redis->connect($cacheOptions['host'], $cacheOptions['port']);

            if (isset($cacheOptions['password'])) {
                $redis->auth($cacheOptions['password']);
            }

            $cache = new RedisCache;
            $cache->setRedis($redis);

            return $cache;
        });

        $container['orm.cache.factory.array'] = $container->protect(function () {
            return new ArrayCache;
        });

        $container['orm.cache.factory.apc'] = $container->protect(function () {
            return new ApcCache;
        });

        $container['orm.cache.factory.xcache'] = $container->protect(function () {
            return new XcacheCache;
        });

        $container['orm.cache.factory.filesystem'] = $container->protect(function ($cacheOptions) {
            if (empty($cacheOptions['path'])) {
                throw new \RuntimeException('FilesystemCache path not defined');
            }

            $cacheOptions += array(
                'extension' => FilesystemCache::EXTENSION,
                'umask' => 0002,
            );
            return new FilesystemCache($cacheOptions['path'], $cacheOptions['extension'], $cacheOptions['umask']);
        });

        $container['orm.cache.factory.couchbase'] = $container->protect(function($cacheOptions){
          $host='';
          $bucketName='';
          $user='';
          $password='';
          if (empty($cacheOptions['host'])) {
            $host='127.0.0.1';
          }
          if (empty($cacheOptions['bucket'])) {
            $bucketName='default';
          }
          if (!empty($cacheOptions['user'])) {
            $user=$cacheOptions['user'];
          }
          if (!empty($cacheOptions['password'])) {
            $password=$cacheOptions['password'];
          }

          $couchbase = new \Couchbase($host,$user,$password,$bucketName);
          $cache = new CouchbaseCache();
          $cache->setCouchbase($couchbase);
          return $cache;
        });

        $container['orm.cache.factory'] = $container->protect(function ($driver, $cacheOptions) use ($container) {
            $cacheFactoryKey = 'orm.cache.factory.'.$driver;
            if (!isset($container[$cacheFactoryKey])) {
                throw new \RuntimeException("Factory '$cacheFactoryKey' for cache type '$driver' not defined (is it spelled correctly?)");
            }

            return $container[$cacheFactoryKey]($cacheOptions);
        });

        $container['orm.mapping_driver_chain.locator'] = $container->protect(function ($name = null) use ($container) {
            $container['orm.ems.options.initializer']();

            if (null === $name) {
                $name = $container['orm.ems.default'];
            }

            $cacheInstanceKey = 'orm.mapping_driver_chain.instances.'.$name;
            if (isset($container[$cacheInstanceKey])) {
                return $container[$cacheInstanceKey];
            }

            return $container[$cacheInstanceKey] = $container['orm.mapping_driver_chain.factory']($name);
        });

        $container['orm.mapping_driver_chain.factory'] = $container->protect(function ($name) use ($container) {
            return new MappingDriverChain;
        });

        $container['orm.add_mapping_driver'] = $container->protect(function (MappingDriver $mappingDriver, $namespace, $name = null) use ($container) {
            $container['orm.ems.options.initializer']();

            if (null === $name) {
                $name = $container['orm.ems.default'];
            }

            /** @var MappingDriverChain $driverChain */
            $driverChain = $container['orm.mapping_driver_chain.locator']($name);
            $driverChain->addDriver($mappingDriver, $namespace);
        });

        $container['orm.strategy.naming'] = function($container) {
            return new DefaultNamingStrategy;
        };

        $container['orm.strategy.quote'] = function($container) {
            return new DefaultQuoteStrategy;
        };

        $container['orm.entity_listener_resolver'] = function($container) {
            return new DefaultEntityListenerResolver;
        };

        $container['orm.repository_factory'] = function($container) {
            return new DefaultRepositoryFactory;
        };

        $container['orm.em'] = function ($container) {
            $ems = $container['orm.ems'];

            return $ems[$container['orm.ems.default']];
        };

        $container['orm.em.config'] = function ($container) {
            $configs = $container['orm.ems.config'];

            return $configs[$container['orm.ems.default']];
        };
    }
1073975
public function register(Container $container)
    {
        $container['extensions.sections'] = function ($c) {
            return new Sections($c['section.factory'], $c['events']);
        };

        $container['extensions.helpers'] = function ($c) {
            return new Helpers($c['escaper'], $c['options']);
        };

        $container['extensions.walker'] = function ($c) {
            return new Walker($c['command'], $c['escaper'], $c['options']);
        };

        $container['extensions.filters'] = function () {
            return new Filters();
        };

        $container['extensions.aura_html'] = function ($c) {
            return new AuraHtmlExtension(
                $c['aura.html.locator'],
                $c['options']['html_tags_functions']
            );
        };
    }
448417
public function register(ContainerInterface $container, Configurable $config)
    {
        if ( ! $config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }
        
        $validator = Validation::createValidatorBuilder();

        if ($config->annotationMapping) {
            $validator->enableAnnotationMapping();
        }

        $container->add($config->getServiceName(), $validator->getValidator());
    }
911825
protected function setupContainer(Container $container)
    {
        $this->container = $container;

        if (!$this->container->has('config')) {
            $this->container['config'] = new Fluent;
        }
    }
1244890
public function register(Container $container)
    {
        /** @var Config $configuration */
        $configuration = $container['config'];

        $logger = Logger::get();
        $logger->setLogLevel($configuration->logLevel);

        return $logger;
    }
461173
public function process(ContainerBuilder $container)
    {
        if (!$container->has($this->getCollectorServiceName())) {
            return;
        }

        $definition = $container->findDefinition(
            $this->getCollectorServiceName()
        );

        $taggedServices = $this->findAndSortTaggedServices(
            $this->getTagName(),
            $container
        );

        /*
         * Per each service, add a new method call reference
         */
        foreach ($taggedServices as $service) {
            $definition->addMethodCall(
                $this->getCollectorMethodName(),
                [$service]
            );
        }
    }
565239
public function register(Container $container)
    {
        $container->share(get_class($this->package), $this->package)
            ->bindShared(AbstractPackage::class, get_class($this->package));

        $container->share('controller.resolver', function (Container $container) {
            return new ControllerResolver($this->package, $container);
        });

        $container->share('repository.resolver', function (Container $container) {
            return new RepositoryResolver($this->package, $container);
        })->alias('model.resolver', 'repository.resolver');

        $container->share('view.resolver', function (Container $container) {
            return new ViewResolver($this->package, $container);
        });

        $container->share('mvc.resolver', function (Container $container) {
            return new MvcResolver(
                $container->get('controller.resolver'),
                $container->get('repository.resolver'),
                $container->get('view.resolver')
            );
        });

        if ($this->package->app->isWeb()) {
            // Router
            $container->prepareSharedObject(PackageRouter::class)->alias('router', PackageRouter::class);
        }
    }