Registers services on the given container.

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

@param \Pimple\Container $container Pimple DI Container.
@return void
19202
public function register(Container $container)
    {
        $this->registerConfig($container);
        $this->reggisterDateHelper($container);
        $this->registerSectionServices($container);
        $this->registerNewsServices($container);
        $this->registerEventServices($container);
    }
253731
protected function registerBindings(Container $container, ConfigRepository $config)
    {
        $container->bind(OAuth2Service::class, function ($container) use ($config) {
            return $this->createService($container, $config[self::CONFIG_KEY]);
        });

        $container->alias(OAuth2Service::class, OAuth2ServiceContract::class);
    }
359557
protected function registerAuthExtensions(Container $container)
    {
        /**
         * @param  Container $container The Pimple DI Container.
         * @return Authenticator
         */
        $container['admin/authenticator'] = function (Container $container) {
            return new Authenticator([
                'logger'        => $container['logger'],
                'user_type'     => User::class,
                'user_factory'  => $container['model/factory'],
                'token_type'    => AuthToken::class,
                'token_factory' => $container['model/factory']
            ]);
        };

        /**
         * For 'charcoal-ui'
         *
         * @todo   Do this right!
         * @param  Container $container The Pimple DI Container.
         * @return Authenticator
         */
        $container['authenticator'] = function (Container $container) {
            return $container['admin/authenticator'];
        };

        /**
         * @param  Container $container The Pimple DI container.
         * @return Authorizer
         */
        $container['admin/authorizer'] = function (Container $container) {
            return new Authorizer([
                'logger'   => $container['logger'],
                'acl'      => $container['admin/acl'],
                'resource' => 'admin'
            ]);
        };

        /**
         * For 'charcoal-ui'
         *
         * @todo   Do this right!
         * @param  Container $container The Pimple DI Container.
         * @return Authorizer
         */
        $container['authorizer'] = function (Container $container) {
            return $container['admin/authorizer'];
        };
    }
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;
    }
596755
public function register(Container $container)
    {
        $container["tplLoader.service"] = function (Container $container) {
            $loader = new \SlaxWeb\View\Loader\PHP($container["response.service"], $container["logger.service"]());
            return $loader->setTemplateExt($container["config.service"]["view.templateExtension"]);
        };
    }
1278841
public function boot(Container $container)
    {
        // register an extension
        $container['events']->on(
            'f.extension.load',
            function (Extension $extension, array $options, $safe) use ($container) {
                $extension->setup($options);
                $container['command']->registerFunctions($extension->provideFunctions(), $safe);
                $container['command']->registerFilters($extension->provideFilters());
                if ($extension instanceof TemplateAware) {
                    $extension->setStack($container['template.stack']);
                }
                if ($extension instanceof FinderAware) {
                    $extension->setFinder($container['template.finder']);
                }
                if ($extension instanceof EngineAware) {
                    $extension->setEngine($container['engine']);
                }
                $container['events']->fire('f.extension.registered', $extension);
            }
        );

        // register a function
        $container['events']->on(
            'f.function.register',
            function ($function, callable $callback, $safe) use ($container) {
                $container['command']->registerFunctions([$function => $callback], $safe);
            }
        );

        // register a filter
        $container['events']->on(
            'f.filter.register',
            function ($filter, callable $callback) use ($container) {
                $container['command']->registerFilters([$filter => $callback]);
            }
        );

        $container['events']->on('f.bootstrapped', function () use ($container) {
            $container['command']->lock();
        });
    }
679563
public static function initContainer($container)
    {
        if ($container instanceof \Pimple\Container) {
            static::$container = $container;
            static::$logger = static::$container
                ->offsetGet(\oat\oatbox\log\LoggerService::SERVICE_ID)
                ->getLogger();
        }
    }
529829
public function register(Container $container)
    {
        $settings = $container->get('settings');

        if (!isset($settings['logger'])) {
            throw new InvalidArgumentException('Logger configuration not found');
        }

        $basename = isset($settings['basename']) ? $settings['basename'] : 'slim-app';

        $container['logger'] = new Monolog($basename, $settings['logger']);
    }
468562
public function register(Container $container)
    {
        /**
         * @param Container $container A container instance.
         * @return Container The Collection of DatabaseSourceConfig, in a Container.
         */
        $container['databases/config'] = function (Container $container) {
            $config = $container['config'];
            $databases = $config['databases'];
            $configs = new Container();
            foreach ($databases as $dbIdent => $dbOptions) {
                $configs[$dbIdent] = function () use ($dbOptions) {
                    return new DatabaseConfig($dbOptions);
                };
            }
            return $configs;
        };

        /**
         * @param Container $container A container instance.
         * @return Container
         */
        $container['databases'] = function (Container $container) {
            $config = $container['config'];
            $databases = $config['databases'];
            $dbs = new Container();
            $origContainer = $container;
            foreach ($databases as $dbIdent => $dbOptions) {
                unset($dbOptions);

                /**
                 * @param Container $container A container instance.
                 * @return PDO
                 */
                $dbs[$dbIdent] = function () use ($dbIdent, $origContainer) {
                    $dbConfigs = $origContainer['databases/config'];
                    $dbConfig = $dbConfigs[$dbIdent];

                    $type = $dbConfig['type'];
                    $host = $dbConfig['hostname'];

                    $database = $dbConfig['database'];
                    $username = $dbConfig['username'];
                    $password = $dbConfig['password'];

                    // Set UTf-8 compatibility by default. Disable it if it is set as such in config
                    $extraOptions = null;
                    if (!isset($dbConfig['disable_utf8']) || !$dbConfig['disable_utf8']) {
                        $extraOptions = [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'];
                    }

                    if ($type == 'sqlite') {
                        $dsn = $type.':'.$database;
                    } else {
                        $dsn = $type.':host='.$host.';dbname='.$database;
                    }
                    $db = new PDO($dsn, $username, $password, $extraOptions);

                    // Set PDO options
                    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                    if ($type == 'mysql') {
                        $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
                    }
                    return $db;
                };
            }
            return $dbs;
        };

        /**
         * The (default) database configuration.
         *
         * @param Container $container A container instance.
         * @return DatabaseSourceConfig
         */
        $container['database/config'] = function (Container $container) {
            $config = $container['config'];
            $databaseIdent = $config['default_database'];
            return $container['databases/config'][$databaseIdent];
        };

        /**
         * The (default) database service, as a PDO object.
         *
         * @param Container $container A container instance.
         * @throws Exception If the database configuration is invalid.
         * @return PDO
         */
        $container['database'] = function (Container $container) {
            $config = $container['config'];
            $databaseIdent = $config['default_database'];
            $databases = $container['databases'];
            if (!isset($databases[$databaseIdent])) {
                throw new Exception(
                    sprintf('The database "%s" is not defined in the "databases" configuration.', $databaseIdent)
                );
            }
            return $databases[$databaseIdent];
        };
    }
127004
public function register(Container $container)
    {
        /** @var Config $configuration */
        $configuration = $container['config'];

        /** @var LoggerInterface $logger */
        $logger = $container['logger'];

        /** @var Client $http */
        $http = $container['http'];

        return new TierConfiguration($configuration, $logger, $http, $container);
    }
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))
        ));
    }
75586
protected function registerFactoryServices(Container $container)
    {
        /**
         * @param  Container $container The Pimple DI container.
         * @return FactoryInterface
         */
        $container['property/input/factory'] = function (Container $container) {
            return new Factory([
                'base_class'       => PropertyInputInterface::class,
                'arguments'        => [[
                    'container' => $container,
                    'logger'    => $container['logger']
                ]],
                'resolver_options' => [
                    'suffix' => 'Input'
                ]
            ]);
        };

        /**
         * @param  Container $container The Pimple DI container.
         * @return FactoryInterface
         */
        $container['property/display/factory'] = function (Container $container) {
            return new Factory([
                'base_class'       => PropertyDisplayInterface::class,
                'arguments'        => [[
                    'container' => $container,
                    'logger'    => $container['logger']
                ]],
                'resolver_options' => [
                    'suffix' => 'Display'
                ]
            ]);
        };

        /**
         * @param  Container $container A Pimple DI container.
         * @return FactoryInterface
         */
        $container['secondary-menu/group/factory'] = function (Container $container) {
            return new Factory([
                'base_class'       => SecondaryMenuGroupInterface::class,
                'default_class'    => GenericSecondaryMenuGroup::class,
                'arguments'        => [[
                    'container'      => $container,
                    'logger'         => $container['logger'],
                    'view'           => $container['view'],
                    'layout_builder' => $container['layout/builder']
                ]],
                'resolver_options' => [
                    'suffix' => 'SecondaryMenuGroup'
                ]
            ]);
        };
    }
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);
    }
29573
public function register(ContainerInterface $container)
    {
        if (! isset($container['session'])) {
            $container['session'] = function (ContainerInterface $container) {
                return new Session;
            };
        }

        if (! isset($container['router'])) {
            /**
             * This service MUST return a SHARED instance
             * of Mbh\Interfaces\RouterInterface.
             *
             * @param Container $container
             * @return RouterInterface
             */
            $container['router'] = function (ContainerInterface $container) {
                $routerCacheFile = false;
                if (isset($container->get('settings')['routerCacheFile'])) {
                    $routerCacheFile = $container->get('settings')['routerCacheFile'];
                }

                $router = (new Router)->setCacheFile($routerCacheFile);
                if (method_exists($router, 'setContainer')) {
                    $router->setContainer($container);
                }

                if (method_exists($router, 'setCallableResolver')) {
                    $router->setCallableResolver($container['callableResolver']);
                }

                return $router;
            };
        }
    }
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);
    }
675450
public function register(Container $container)
    {
        $config = $container->get('config');

        if ($config->get('system.debug')) {
            $whoops = new Whoops();

            $handler = new PrettyPageHandler();
            $handler->setEditor($config->get('whoops.editor', 'phpstorm'));

            $whoops->pushHandler($handler);

            $container->share(Whoops::class, $whoops)
                ->alias('whoops', Whoops::class);

            $container->share(PrettyPageHandler::class, $handler)
                ->alias('whoops.handler', PrettyPageHandler::class);
        }
    }
1325100
public function register(Container $container)
    {
        /** @var Config $configuration */
        $configuration = $container['config'];

        /** @var LoggerInterface $logger */
        $logger = $container['logger'];

        /** @var Client $http */
        $http = $container['http'];

        /** @var TierConfiguration $tierConfiguration */
        $tierConfiguration = $container['tierConfiguration'];

        return new Fulfillment($configuration, $logger, $http, $tierConfiguration);
    }