Registers the service provider with a DI container.

@param   Container $container The DI container.

@return  void
484427
public function register(Container $container)
    {
        $closure = function (Container $container) {
            $manager = $container->newInstance(LoggerManager::class, [
                'logPath' => $container->get('config')->get('path.logs')
            ]);

            return $manager;
        };

        $container->share(LoggerManager::class, $closure);
    }
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);
        }
    }
311417
public function register(Container $container)
    {
        $config = $container->get('config')->get('cache');

        $container->add('cache', new CachePool($config));

        unset($config);
    }
1175527
public function register(Container $container)
    {
        $container->share(HandlerInterface::class, [$this, 'handler']);
        $container->share(AbstractDatabaseAdapter::class, [$this, 'dbAdapter']);

        $container->bind(SessionBagInterface::class, SessionBag::class);
        $container->bind(FlashBagInterface::class, FlashBag::class);
        $container->bind(SessionBridgeInterface::class, NativeBridge::class);

        $closure = function (Container $container) {
            /** @var \Windwalker\Structure\Structure $config */
            $config = $container->get('config');
            $uri    = $container->get('uri');

            $options = (array) $config->get('session', []);

            $options['cookie_path']   = !empty($options['cookie_path']) ? $options['cookie_path'] : $uri->path;
            $options['cookie_domain'] = parse_url($uri->host, PHP_URL_HOST);

            return $container->newInstance(Session::class, ['options' => $options]);
        };

        $container->share(Session::class, $closure);
    }
262321
public function register(Container $container)
    {
        // Get cache factory object.
        $container->prepareSharedObject(CacheManager::class);

        // Get global cache object.
        $container->share(Cache::class, function (Container $container) {
            /** @var Structure $config */
            $config = $container->get('config');

            $storage = $config->get('cache.storage', 'file');
            $handler = $config->get('cache.serializer', 'php');

            return $container->get(CacheManager::class)->create('windwalker', $storage, $handler);
        });
    }
690980
public function register(Container $container)
    {
        $this->registerViewConfig($container);
        $this->registerLoaderServices($container);
        $this->registerEngineServices($container);
        $this->registerMustacheTemplatingServices($container);
        $this->registerTwigTemplatingServices($container);
        $this->registerViewServices($container);
    }
435074
public function register(Container $container)
    {
        $container->share(Container::class, $container);

        $container->share(get_class($this->app), $this->app)
            ->bindShared(WindwalkerApplicationInterface::class, get_class($this->app));

        $container->share(Config::class, $this->config);

        $container->prepareSharedObject(PackageResolver::class);

        $this->registerClassAlias();
    }
613530
public function register(ServiceContainer $container)
    {
        if ($this->registrationFunction !== null) {
            call_user_func($this->registrationFunction, $container);
        }
    }
58009
protected function setDependencies(Container $container)
    {
        parent::setDependencies($container);

        $this->setLocales($container['locales/manager']->locales());
    }
840055
private function registerService(ContainerBuilder $container, $serviceId, $serviceClass)
    {
        if (class_exists($serviceClass)) {
            $container->register($serviceId, $serviceClass);
        }
    }
416587
public function register(Container $container)
    {
        $container = $container->getParent();

        // System profiler
        $closure = function (Container $container) {
            $config = $container->get('config');

            if ($config->get('system.debug')) {
                $profiler = new Profiler('windwalker');

                $profiler->setPoint(new Point(
                    'start',
                    $config['execution.start'] ?: microtime(true),
                    $config['execution.memory'] ?: memory_get_usage(true),
                    ['tag' => 'system.process']
                ));

                return $profiler;
            }

            return new NullProfiler();
        };

        $container->share('profiler', $closure);

        // System collector
        $closure = function (Container $container) {
            $config = $container->get('config');

            if ($config->get('system.debug')) {
                return new Structure();
            } else {
                return new NullObject();
            }
        };

        $container->share('debugger.collector', $closure);

        if ($container->get('config')->get('system.debug')) {
            $this->registerProfilerListener($container, $container->get('config'));
            $this->registerDatabaseProfiler($container, $container->get('config'));
            $this->registerEmailProfiler($container, $container->get('config'));
            $this->registerLogsProfiler($container, $container->get('config'));
        }
    }
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];
        };
    }
653638
public function register(Container $container)
    {
        $dir = app()->getPath().'/config';
        $config = $container->get('config');
        $config->load($dir.'/config.php');
        $config->merge([
            'database' => load($dir.'/database.php'),
            'cache' => load($dir.'/cache.php'),
        ]);
        if (file_exists(app()->getPath().'/.env.yml')) {
            $config->merge(load(app()->getPath().'/.env.yml'));
        }
    }
1354977
public function register(Container $app)
    {
        $app[DataInterface::class] = $app->factory(Data::class);
        $app[ConfigInterface::class] = $app->factory(FileConfig::class);
    }
815953
public function define(Container $di)
    {
        foreach ($this->params as $key => $value) {
            if (! isset($di->values[$key])) {
                $di->values[$key] = $value;
            }
        }

        $this->defineView($di);
        $this->defineHelpers($di);
    }
171023
public function register(Container $pimple)
    {
        $pimple["$this->prefix.config"] = $this->defineDefaultConfig();
        $pimple["$this->prefix.command_bus"] = $this->setUpCommandBus($pimple);
        $pimple["$this->prefix.event_bus"] = $this->setUpEventBus();
        $pimple["$this->prefix.event_store"] = $this->setUpEventStore($pimple);
        $pimple["$this->prefix.snapshot_store"] = $this->setUpSnapshotStore($pimple);
        $pimple["$this->prefix.snapshotter"] = $this->setUpSnapshotter($pimple);
        $pimple["$this->prefix.repository.aggregate"] = $this->setUpAggregateRepository();
        $pimple["$this->prefix.serializer"] = $this->setUpSerializer($pimple);
    }
252119
public function register(Container $container)
    {
        if (!isset($container['console'])) {
            throw new \LogicException('You must register the ConsoleServiceProvider to use the WebServerServiceProvider.');
        }

        $container['web_server.document_root'] = null;
        $container['web_server.environment'] = 'dev';

        $commands = [
            'server:run' => 'web_server.command.server_run',
            'server:start' => 'web_server.command.server_start',
            'server:stop' => 'web_server.command.server_stop',
            'server:status' => 'web_server.command.server_status',
        ];

        $container['web_server.command.server_run'] = function (Container $container) {
            if (null === $docRoot = $container['web_server.document_root']) {
                throw new \LogicException('You must set the web_server.document_root parameter to use the development web server.');
            }

            return new ServerRunCommand($docRoot, $container['web_server.environment']);
        };

        $container['web_server.command.server_start'] = function (Container $container) {
            if (null === $docRoot = $container['web_server.document_root']) {
                throw new \LogicException('You must set the web_server.document_root parameter to use the development web server.');
            }

            return new ServerStartCommand($docRoot, $container['web_server.environment']);
        };

        $container['web_server.command.server_stop'] = function () {
            return new ServerStopCommand();
        };

        $container['web_server.command.server_status'] = function () {
            return new ServerStatusCommand();
        };

        if (class_exists(ConsoleFormatter::class)) {
            $container['web_server.command.server_log'] = function () {
                return new ServerLogCommand();
            };
            $commands['server:log'] = 'web_server.command.server_log';
        }

        $container['console.command.ids'] = array_merge($container['console.command.ids'], $commands);
    }