Registers services on the given app.

@param Container $app An Application instance.
322505
public function register(Container $app): void
    {
        $app[self::TEMPLATE_FOLDER] = __DIR__ . '/data/templates/';
        $app[self::CONVERTERS] = [
            '\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\ToHtml' => [Format::RST, Format::HTML],
        ];

        $app[self::FORMATS] = function () {
            return new Converter\Format\Collection();
        };

        $app[self::CONVERTER_DEFINITION_FACTORY] = function ($container) {
            return new Factory($container[self::FORMATS]);
        };

        $app[self::CONVERTER_FACTORY] = function ($container) {
            return new Converter\Factory(
                $container['converters'],
                $container['converter_definition_factory'],
                $container['monolog']
            );
        };

        $app[self::TEMPLATE_FACTORY] = function ($app) {
            return new Template\Factory(
                ['twig' => new Template\Twig($app[self::TEMPLATE_FOLDER])]
            );
        };

        $this->addCommands($app);
    }
356637
public function bootstrap(Container $app)
    {
        foreach ($app->make('config')->get('app.services') as $key => $services) {
            foreach ((array) $services as $service) {
                $app->alias($key, $service);
            }
        }
        
        foreach ($app->make('config')->get('app.theme.services', []) as $key => $services) {
            foreach ((array) $services as $service) {
                $app->alias($key, $service);
            }
        }
    }
804644
public function register(PimpleContainer $app)
    {
        $app['capsule.connectionDefault'] = [
            'driver' => 'mysql',
            'host' => 'localhost',
            'port' => 3306,
            'database' => null,
            'username' => null,
            'password' => null,
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => false,
            'engine' => null,
        ];

        $app['capsule.connections'] = [];

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

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

        $app['capsule.options'] = [
            'setAsGlobal' => true,
            'bootEloquent' => true,
            'enableQueryLog' => true,
        ];

        $app['capsule'] = function (PimpleContainer $app) {
            $capsule = new Capsule($app['capsule.container']);

            // Set the event dispatcher used by Eloquent models...
            if (!empty($app['capsule.dispatcher'])) {
                $capsule->setEventDispatcher($app['capsule.dispatcher']);
            }

            // Connections
            foreach ($app['capsule.connections'] as $connectionName => $connectionConfig) {
                $connectionConfig += $app['capsule.connectionDefault'];
                $capsule->addConnection($connectionConfig, $connectionName);

                if ($app['capsule.options']['enableQueryLog']) {
                    $capsule->getConnection($connectionName)->enableQueryLog();
                }
            }

            // Make this Capsule instance available globally via static methods...
            if (!empty($app['capsule.options']['setAsGlobal'])) {
                $capsule->setAsGlobal();
            }

            // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
            if (!empty($app['capsule.options']['bootEloquent'])) {
                $capsule->bootEloquent();
            }

            return $capsule;
        };
    }
196827
public function register(Application $app)
    {
        $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig, $app) {
            $twig->setCache($app['cache.path'] . '/twig');

            $paths = [];

            if (file_exists($app['plugin.path'] . '/twig-paths.php')) {
                $paths = require $app['plugin.path'] . '/twig-paths.php';
            }

            if ($app['browser']->isTablet() || $app['browser']->isMobile()) {
                $paths[] = $app['root.path'] . '/config/templates/mobile';
                $paths[] = $app['root.path'] . '/templates/mobile';
                $paths['phraseanet'] = $app['root.path'] . '/config/templates/mobile';
                $paths['phraseanet'] = $app['root.path'] . '/templates/mobile';
            }

            $paths[] = $app['root.path'] . '/config/templates/web';
            $paths[] = $app['root.path'] . '/templates/web';
            $paths['phraseanet'] = $app['root.path'] . '/config/templates/web';
            $paths['phraseanet'] = $app['root.path'] . '/templates/web';

            foreach ($paths as $namespace => $path) {
                if (!is_int($namespace)) {
                    $app['twig.loader.filesystem']->addPath($path, $namespace);
                } else {
                    $app['twig.loader.filesystem']->addPath($path);
                }
            }

            $twig->addGlobal('current_date', new \DateTime());

            $this->registerExtensions($twig, $app);
            $this->registerFilters($twig, $app);

            return $twig;
        }));
    }
140012
public function register(Container $container)
    {
        $container->prepareSharedObject(RendererManager::class, [$this, 'manager']);
        $container->prepareSharedObject(PackageFinder::class);
        $container->share(WidgetManager::class, [$this, 'widget']);
    }
690980
public function register(Container $container)
    {
        $this->registerViewConfig($container);
        $this->registerLoaderServices($container);
        $this->registerEngineServices($container);
        $this->registerMustacheTemplatingServices($container);
        $this->registerTwigTemplatingServices($container);
        $this->registerViewServices($container);
    }
777610
public function register(App $app)
    {
        $app["logger.service"] = $app->protect(
            function (string $loggerName = "") use ($app) {
                $cacheName = "logger.service-{$loggerName}";
                if (isset($app[$cacheName])) {
                    return $app[$cacheName];
                }
                /*
                 * Check the config service has been defined and provides correct
                 * object
                 */
                if (isset($app["config.service"]) === false
                    || get_class($app["config.service"]) !== "SlaxWeb\\Config\\Container") {
                    throw new \SlaxWeb\Bootstrap\Exception\LoggerConfigException(
                        "Config component provider must be registered before you can use the Logger component."
                    );
                }

                $config = $app["config.service"];
                if ($loggerName === "") {
                    $loggerName = $config["logger.defaultLogger"];
                }

                $logger = new MLogger($loggerName);
                foreach ($config["logger.loggerSettings"][$loggerName] as $type => $settings) {
                    // load propper handler and instantiate the Monolog\Logger
                    $handler = null;
                    switch ($type) {
                        case Helper::L_TYPE_FILE:
                            $app["temp.logger.settings"] = $settings;
                            $handler = $app["logger.{$type}.service"];
                            unset($app["temp.logger.settings"]);
                            break;
                        default:
                            throw new \SlaxWeb\Bootstrap\Exception\UnknownLoggerHandlerException(
                                "The handler you are tring to use is not known or not supported."
                            );
                    }
                    $logger->pushHandler($handler);
                }

                return $app[$cacheName] = $logger;
            }
        );

        $app["logger.StreamHandler.service"] = $app->factory(
            function (App $cont) {
                $settings = $cont["temp.logger.settings"];

                // if the log file name does not begin with a dir separator, treat
                // it as relative path and prepend 'logFilePath'
                if ($settings[0][0] !== DIRECTORY_SEPARATOR) {
                    $settings[0] = ($cont["config.service"]["logger.logFilePath"] ?? "")
                        . $settings[0];
                }
                return new \Monolog\Handler\StreamHandler(...$settings);
            }
        );
    }
325895
protected function registerAutoloader($app)
    {
        // now configure a new autoloader spl configuration
        $autoloaderApp = new Doozr_Loader_Autoloader_Spl_Config();
        $autoloaderApp
            ->_namespace($app->namespace)
            ->namespaceSeparator('_')
            ->addExtension('php')
            ->path(substr($app->path, 0, -1))
            ->description('Autoloader for App classes with namespace: "'.$app->namespace.'"')
            ->priority(0);

        Doozr_Loader_Autoloader_Spl_Facade::attach([$autoloaderApp]);
    }
435594
public function registerAutoPresenterMapper(Container $app)
    {
        $app->singleton('autopresentermapper', function () {
            return new AutoPresenterMapper();
        });

        $autoPresenter = $app->make('autopresenter');
        $autoPresenter->register(new MapperDecorator($autoPresenter, $this->app->make('autopresentermapper'), $this->app));
    }
368059
public function register(Application $app)
    {
        if ($this->registered) {
            throw new \RuntimeException('Can not re-register extensions.');
        }
        foreach ($this->extensions as $extension) {
            if ($extension->isEnabled() !== true) {
                continue;
            }
            $extension->getInnerExtension()->setContainer($app);
            foreach ($extension->getInnerExtension()->getServiceProviders() as $provider) {
                $app->register($provider);
            }
        }
        $this->registered = true;

        // @deprecated Deprecated since 3.0, to be removed in 4.0.
        $this->app = $app;
    }
319283
public function register(Container $container)
    {
        // Authentication
        $container->share(Authentication::class, [$this, 'authentication'])
            ->bindShared(AuthenticationInterface::class, Authentication::class);

        // Authorisation
        $container->share(Authorisation::class, [$this, 'authorisation'])
            ->bindShared(AuthorisationInterface::class, Authorisation::class);

        // User Handler
        $this->prepareHandler($container);

        // User Manager
        $container->prepareSharedObject(UserManager::class);
    }
393725
public function register($app)
    {
        if (! $this->cache->get('telescope:dump-watcher')) {
            return;
        }

        VarDumper::setHandler(function ($var) {
            $this->recordDump((new HtmlDumper)->dump(
                (new VarCloner)->cloneVar($var), true
            ));
        });
    }
1211900
public function register(Container $container)
    {
        $container->prepareSharedObject(CoreLanguage::class)
            ->bindShared(Language::class, CoreLanguage::class)
            ->bindShared(LanguageInterface::class, CoreLanguage::class);
    }
305723
public function register(Container $container)
    {
        $app = $container->get('application');

        $container->share(WebApplication::class, $app);

        // Input
        $container->share(Input::class, function (Container $container) use ($app) {
            return PsrInput::create($app->getRequest());
        })->bindShared(PsrInput::class, Input::class);

        // Request
//        $container->share(ServerRequest::class, $app->getRequest())
//            ->alias(ServerRequestInterface::class, ServerRequest::class);

        // Environment
        $container->share(WebEnvironment::class, $app->getEnvironment());
        $container->share(Browser::class, $app->getEnvironment()->getBrowser());
        $container->share(Platform::class, $app->getEnvironment()->getPlatform());

        // Uri
        $container->share(UriData::class, function (Container $container) use ($app) {
            return $app->getServer()->getUriData();
        });
    }
1291242
public function register(Application $app)
    {
        $app["loadController.service"] = $app->protect(
            function (string $name) use ($app) {
                $args = func_get_args();
                $cacheName = "loadController.service-{$name}";
                if (isset($app[$cacheName])) {
                    return $app[$cacheName];
                }

                $config = $app["config.service"];
                $class = rtrim($config["app.controllerNamespace"], "\\")
                    . "\\"
                    . str_replace("/", "\\", $name);
                $app[$cacheName] = new $class($app);

                if (method_exists($app[$cacheName], "init")) {
                    array_shift($args);
                    $app[$cacheName]->init(...$args);
                }

                return $app[$cacheName];
            }
        );
    }
74301
public function register(Container $app)
    {
        $this->kernel                        = $app;
        $app['request_matcher']              = $app->extend(
            'request_matcher',
            function ($urlMatcher, $c) {
                $context = $c['request_context'];
                
                $newMatcher = new GroupUrlMatcher(
                    $context,
                    [
                        new CacheableRouterUrlMatcherWrapper(
                            $this->getRouter($context)->getMatcher(),
                            $c['routing.config.namespaces']
                        ),
                        $urlMatcher,
                    ]
                );
                
                return $newMatcher;
            }
        );
        $app['url_generator']                = $app->extend(
            'url_generator',
            function ($generator, $kernel) {
                /** @var SilexKernel $kernel */
                
                /** @var RequestContext $context */
                //$context = $kernel['request_context'];
                /** @var Router $router */
                $router       = $kernel['router'];
                $newGenerator = $router->getGenerator();
                
                //$newGenerator = new UrlGenerator($router->getRouteCollection(), $context);
                
                return new GroupUrlGenerator(
                    [
                        $newGenerator,
                        $generator,
                    ]
                );
            }
        );
        $app['router']                       = function ($app) {
            return $this->getRouter($app['request_context']);
        };
        $app['routing.config.data_provider'] = function ($app) {
            $routingConfig = $app['routing.config'];
            
            return $this->processConfiguration(
                $routingConfig,
                new CacheableRouterConfiguration()
            );
        };
        $app['routing.config.namespaces']    = function () {
            return $this->getConfigDataProvider()->getOptional(
                'namespaces',
                DataProviderInterface::ARRAY_TYPE,
                []
            );
        };
        $app['routing.config.cache_dir']     = function () {
            return $this->getConfigDataProvider()->getOptional('cache_dir');
        };
    }
938017
public function resetApp(Container $app)
    {
        foreach ($this->resetters as $resetter) {
            $resetter->handle($app, $this);
        }
    }