Registers services on the given container.

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

@param Container $pimple A container instance
161523
public function register(Container $pimple)
    {
        $pimple['encryptor'] = function ($pimple) {
            return new Encryptor(
                $pimple['open_platform_config']['app_id'],
                $pimple['open_platform_config']['token'],
                $pimple['open_platform_config']['aes_key']
            );
        };

        $pimple['server'] = function ($pimple) {
            $server = new Guard($pimple['open_platform_config']['token']);
            $server->setAppId($pimple['config']['app_id']);

            $server->debug($pimple['config']['debug']);

            $server->setEncryptor($pimple['encryptor']);

            $server->setTestMessageHandler($this->getTestMessageHandler($pimple));

            return $server;
        };
    }
1211900
public function register(Container $container)
    {
        $container->prepareSharedObject(CoreLanguage::class)
            ->bindShared(Language::class, CoreLanguage::class)
            ->bindShared(LanguageInterface::class, CoreLanguage::class);
    }
1354977
public function register(Container $app)
    {
        $app[DataInterface::class] = $app->factory(Data::class);
        $app[ConfigInterface::class] = $app->factory(FileConfig::class);
    }
34288
public function registerServices(DiInterface $di)
    {
        // registering view
        $config = $di->get('config');
        $view = $di->get('view');
        $view->setViewsDir(__DIR__. '/views/');
        $view->setMainView('main');
        $view->setLayoutsDir($config->application->layoutsDir);
        $view->setPartialsDir($config->application->adminPartialDir );
        $view->setLayout('private');
    }
459876
public function register(PimpleContainer $app)
    {
        $app['capsule.connection_defaults'] = [
            'driver' => 'mysql',
            'host' => 'localhost',
            'database' => null,
            'username' => 'root',
            'password' => null,
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => null,
            'logging' => false,
        ];

        $app['capsule.container'] = function () {
            return new Container();
        };

        $app['capsule.dispatcher'] = function () use ($app) {
            return new Dispatcher($app['capsule.container']);
        };

        if (class_exists('Illuminate\Cache\CacheManager')) {
            $app['capsule.cache_manager'] = function () use ($app) {
                return new CacheManager($app['capsule.container']);
            };
        }

        $app['capsule.eloquent'] = true;

        $app['capsule'] = function ($app) {
            $capsule = new DB($app['capsule.container']);
            $capsule->setEventDispatcher($app['capsule.dispatcher']);

            if (isset($app['capsule.cache_manager']) && isset($app['capsule.cache'])) {
                $capsule->setCacheManager($app['capsule.cache_manager']);

                foreach ($app['capsule.cache'] as $key => $value) {
                    $app['capsule.container']->offsetGet('config')->offsetSet('cache.'.$key, $value);
                }
            }

            if (!isset($app['capsule.connections'])) {
                $app['capsule.connections'] = [
                    'default' => (isset($app['capsule.connection']) ? $app['capsule.connection'] : []),
                ];
            }

            foreach ($app['capsule.connections'] as $connection => $options) {
                $options = array_replace($app['capsule.connection_defaults'], $options);
                $logging = $options['logging'];
                unset($options['logging']);

                $capsule->addConnection($options, $connection);

                if ($logging) {
                    $capsule->getConnection($connection)->enableQueryLog();
                } else {
                    $capsule->getConnection($connection)->disableQueryLog();
                }
            }

            $capsule->bootEloquent();
            $capsule->setAsGlobal();

            $app['db'] = $app->factory(function ($c) {
                return DB::connection();
            });

            return $capsule;
        };
    }
340282
public function register(Container $pimple)
    {
        $pimple['oauth'] = function ($pimple) {
            return new App($pimple['access_token']);
        };

        $pimple['auth'] = function ($pimple) {
            return new Web($pimple['access_token']);
        };

        $auth_work = function ($pimple) {
            return new WorkWeb($pimple['access_token']);
        };

        $pimple['auth_work'] = $auth_work;
        $pimple['auth.work'] = $auth_work;
    }
973301
protected function registerContextOptions(Container $container)
    {
        $defaultOptions = stream_context_get_options(stream_context_get_default());
        stream_context_set_default(array_merge(
            $defaultOptions,
            array($this->scheme => array('Container' => $container))
        ));
    }
280194
public function register(Container $pimple)
    {
        $pimple['singular.service.pack'] = function () use ($pimple) {
            return new PackService(
                $pimple['singular.directory.src'],
                $pimple['singular.directory.app'].DIRECTORY_SEPARATOR."packs"
            );
        };

        $pimple['singular.service.command'] = function() use ($pimple) {
            return new CommandService(
                $pimple['singular.directory.src'],
                $pimple['singular.service.pack']
            );
        };
        
        $pimple['singular.service.service'] = function() use ($pimple) {
            return new ServiceService(
                $pimple['singular.directory.src'],
                $pimple['singular.service.pack']
            );
        };

        $pimple['singular.service.store'] = function() use ($pimple) {
            return new StoreService(
                $pimple['singular.directory.src'],
                $pimple['singular.service.pack']
            );
        };

        $pimple['singular.service.controller'] = function() use ($pimple) {
            return new ControllerService(
                $pimple['singular.directory.src'],
                $pimple['singular.service.pack']
            );
        };

        $pimple['singular.service.module'] = function() use ($pimple) {
            return new ModuleService(
                $pimple['injector.directory.src']
            );
        };

        $pimple['singular.service.menu'] = function() use ($pimple) {
            return new MenuService(
                $pimple['singular.directory.root'],
                $pimple['db']
            );
        };

        $pimple['singular.service.front_controller'] = function() use ($pimple) {
            return new FrontControllerService(
                $pimple['injector.directory.src']
            );
        };

        $pimple['singular.service.front_service'] = function() use ($pimple) {
            return new FrontServiceService(
                $pimple['injector.directory.src']
            );
        };

        $pimple['singular.service.front_view'] = function() use ($pimple) {
            return new FrontViewService(
                $pimple['injector.directory.src']
            );
        };

        $pimple['singular.service.component'] = function() use ($pimple) {
            return new ComponentService(
                $pimple['singular.directory.root'],
                $pimple['db']
            );
        };

        $pimple['singular.command.create_pack'] = function () {
            return new CreatePackCommand();
        };
        
        $pimple['singular.command.disable_pack'] = function () {
            return new DisablePackCommand();
        };

        $pimple['singular.command.enable_pack'] = function () {
            return new EnablePackCommand();
        };

        $pimple['singular.command.create_command'] = function () {
            return new CreateCommandCommand();
        };

        $pimple['singular.command.create_service'] = function () {
            return new CreateServiceCommand();
        };

        $pimple['singular.command.create_controller'] = function () {
            return new CreateControllerCommand();
        };

        $pimple['singular.command.create_store'] = function () {
            return new CreateStoreCommand();
        };

        $pimple['singular.command.create_module'] = function () {
            return new CreateModuleCommand();
        };

        $pimple['singular.command.create_front_controller'] = function () {
            return new CreateFrontControllerCommand();
        };

        $pimple['singular.command.create_front_service'] = function () {
            return new CreateFrontServiceCommand();
        };

        $pimple['singular.command.create_front_view'] = function () {
            return new CreateFrontViewCommand();
        };

        $pimple['singular.command.create_component_migration'] = function () {
            return new CreateComponentMigrationCommand();
        };

        $pimple['singular.command.create_menu_migration'] = function () {
            return new CreateMenuMigrationCommand();
        };

        $pimple['singular.command.grant_full_access'] = function () {
            return new GrantFullAccessCommand();
        };
    }
683764
public function register(\Pimple $container)
    {
        $container['itkg-core.command.db_update.runner'] = $container->share(
            function ($container) {
                return new Runner($container['doctrine.connection']);
            }
        );

        $container['itkg-core.command.db_update.decorator'] = $container->share(
            function () {
                return new DatabaseUpdate\Query\Decorator(
                    new TemplateLoader()
                );
            }
        );

        $container['itkg-core.command.db_update.display'] = $container->share(
            function () {
                return new DatabaseUpdate\Display(
                    new DatabaseUpdate\Layout\Parser(),
                    new Formatter()
                );
            }
        );

        $container['itkg-core.command.db_update.setup'] = $container->share(
            function ($container) {
                return new Setup(
                    $container['itkg-core.command.db_update.runner'],
                    new Loader($container['doctrine.connection']),
                    new Factory(),
                    new Locator(),
                    $container['itkg-core.command.db_update.decorator'],
                    new DatabaseUpdate\ReleaseChecker()
                );
            }
        );

        $container['itkg-core.command.database_update'] = $container->share(
            function ($container) {
                return new DatabaseUpdateCommand(
                    $container['itkg-core.command.db_update.setup'],
                    $container['itkg-core.command.db_update.display'],
                    'itkg-core:database:update'
                );
            }
        );

        $container['itkg-core.command.database_list'] = $container->share(
            function ($container) {
                return new DatabaseListCommand(
                    new Locator(),
                    new Finder(),
                    new DatabaseUpdate\ReleaseChecker(),
                    'itkg-core:database:list'
                );
            }
        );
    }
531612
public function register(Container $container)
    {
        $closure = function (Container $container) {
            $tz = $container->get('config')->get('system.timezone', 'UTC');

            return new Chronos('now', new \DateTimeZone($tz));
        };

        $container->set(Chronos::class, $closure);
    }
1348073
public function register(Container $pimple)
    {
        $config = $this->readConfig();

        foreach ($config as $name => $value) {
            if ('%' === substr($name, 0, 1)) {
                $this->replacements[$name] = preg_replace_callback(
                    '/(%.+%)/U', function ($matches) use ($config) {
                        return $this->replacements[$matches[0]];
                    },
                    (string) $value);
            }
        }

        $this->merge($pimple, $config);
    }
21844
public function register(Container $app)
    {
        $app["cache.service"] = function(Container $app) {
            $handlerClass = ucfirst($app["config.service"]["cache.handler"]);

            return new \SlaxWeb\Cache\Manager(
                $app["cache{$handlerClass}Handler.service"]
            );
        };

        $app["cacheFileHandler.service"] = function(Container $app) {
            return new \SlaxWeb\Cache\Handler\File(
                $app["config.service"]["cache.location"],
                $app["config.service"]["cache.maxAge"]
            );
        };
    }
662173
public function register(ContainerInterface $container)
    {
        $packages = [];

        // TODO : trouver comment ne pas utiliser cette constante !!!!
        $packagesFile = \Chiron\ROOT_DIR . '/bootstrap/cache/packages.php';

        if (file_exists($packagesFile)) {
            $packages = include $packagesFile;
        }

        foreach ($packages as $package) {
            if (! empty($package['providers'])) {
                array_walk($package['providers'], function ($provider) use ($container) {
                    // TODO : faire remonter la méthode "register" directement dans la classe Application
                    $container->register(new $provider);
                });
            }
        }
    }
613530
public function register(ServiceContainer $container)
    {
        if ($this->registrationFunction !== null) {
            call_user_func($this->registrationFunction, $container);
        }
    }
840055
private function registerService(ContainerBuilder $container, $serviceId, $serviceClass)
    {
        if (class_exists($serviceClass)) {
            $container->register($serviceId, $serviceClass);
        }
    }
1318989
public function register(ContainerInterface $container, Configurable $config)
    {
        if (! $config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }

        $logger = new Logger($config->name, $config->handlers);

        $container->add($config->getServiceName(), $logger);
    }
705249
public function register(ServiceContainer $container)
    {
        $container->set(ServiceId::CONFIG_FILE, function () {
            return $this->packageFolder . '/resources/config/config.php';
        });

        $container->set(ServiceId::CONFIG, function (ContainerInterface $container) {
            $path = $container->get(ServiceId::CONFIG_FILE);
            if (!file_exists($path)) {
                throw new RuntimeException('Wrong presentation framework configuration path.');
            }
            $fileName = basename($path);
            list(, $extension) = explode('.', $fileName);
            switch (strtolower($extension)) {
                case 'php':
                    return include($path);
                case 'json':
                    return json_decode(file_get_contents($path));
            }
            throw new RuntimeException('Unsupported configuration file type.');
        });

        $container->set(ServiceId::RENDERER, function (ContainerInterface $container) {
            return new SimpleRenderer($container->get(ServiceId::TEMPLATE_FINDER));
        });

        $container->set(ServiceId::TEMPLATE_FINDER, function () {
            return new TemplateFinder([$this->packageFolder . '/resources/views']);
        });

        $container->set(ServiceId::RESOURCE_MANAGER, function (ContainerInterface $container) {
            $config = $container->get(ServiceId::CONFIG);
            return new ResourceManager(
                new AliasRegistry(isset($config['js_aliases']) ? $config['js_aliases'] : []),
                new AliasRegistry(isset($config['css_aliases']) ? $config['css_aliases'] : []),
                new IncludedResourcesRegistry()
            );
        });

        $container->set(ServiceId::HTML_BUILDER, function (ContainerInterface $container) {
            return new HtmlBuilder($container->get(ServiceId::RESOURCE_MANAGER));
        });

        $container->set(ServiceId::BOOTSTRAP_STYLING_CONFIG, function () {
            return include $this->packageFolder . '/resources/config/styling/twitter_bootstrap.php';
        });

        $container->set(ServiceId::FOUNDATION_STYLING_CONFIG, function () {
            return include $this->packageFolder . '/resources/config/styling/foundation.php';
        });

        $container->set(ServiceId::SEMANTIC_UI_STYLING_CONFIG, function () {
            return include $this->packageFolder . '/resources/config/styling/semantic-ui.php';
        });
    }