/** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void * * @since 1.0 */ public function register(Container $container) { $container->alias('Stats\\Application', 'Joomla\\Application\\AbstractApplication')->alias('Joomla\\Application\\AbstractWebApplication', 'Joomla\\Application\\AbstractApplication')->share('Joomla\\Application\\AbstractApplication', function (Container $container) { $application = new Application($container->get('Joomla\\Input\\Input'), $container->get('config')); // Inject extra services $application->setRouter($container->get('Stats\\Router')); return $application; }, true); $container->share('Joomla\\Input\\Input', function () { return new Input($_REQUEST); }, true); $container->share('Stats\\Router', function (Container $container) { $router = (new Router($container->get('Joomla\\Input\\Input')))->setContainer($container)->setControllerPrefix('Stats\\Controllers\\')->setDefaultController('DisplayController')->addMap('/submit', 'SubmitController')->addMap('/:source', 'DisplayController'); return $router; }, true); $container->share('Stats\\Controllers\\DisplayControllerGet', function (Container $container) { $controller = new DisplayControllerGet($container->get('Stats\\Views\\Stats\\StatsJsonView')); $controller->setApplication($container->get('Joomla\\Application\\AbstractApplication')); $controller->setInput($container->get('Joomla\\Input\\Input')); return $controller; }, true); $container->share('Stats\\Controllers\\SubmitControllerCreate', function (Container $container) { $controller = new SubmitControllerCreate($container->get('Stats\\Models\\StatsModel')); $controller->setApplication($container->get('Joomla\\Application\\AbstractApplication')); $controller->setInput($container->get('Joomla\\Input\\Input')); return $controller; }, true); $container->share('Stats\\Models\\StatsModel', function (Container $container) { return new StatsModel($container->get('Joomla\\Database\\DatabaseDriver')); }, true); $container->share('Stats\\Views\\Stats\\StatsJsonView', function (Container $container) { return new StatsJsonView($container->get('Stats\\Models\\StatsModel')); }, true); }
/** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void * * @since 1.0 */ public function register(Container $container) { $container->alias(Application::class, JoomlaApplication\AbstractApplication::class)->alias(JoomlaApplication\AbstractWebApplication::class, JoomlaApplication\AbstractApplication::class)->share(JoomlaApplication\AbstractApplication::class, function (Container $container) { $application = new Application($container->get(Input::class), $container->get('config')); // Inject extra services $application->setLogger($container->get('monolog.logger.application')); $application->setRouter($container->get(Router::class)); return $application; }, true); $container->share(Input::class, function () { return new Input($_REQUEST); }, true); $container->share(Router::class, function (Container $container) { $router = (new Router($container->get('Joomla\\Input\\Input')))->setContainer($container)->setControllerPrefix('Stats\\Controllers\\')->setDefaultController('DisplayController')->addMap('/submit', 'SubmitController')->addMap('/:source', 'DisplayController'); return $router; }, true); $container->share(DisplayControllerGet::class, function (Container $container) { $controller = new DisplayControllerGet($container->get(StatsJsonView::class)); $controller->setApplication($container->get('Joomla\\Application\\AbstractApplication')); $controller->setInput($container->get('Joomla\\Input\\Input')); return $controller; }, true); $container->share(SubmitControllerCreate::class, function (Container $container) { $controller = new SubmitControllerCreate($container->get('Stats\\Models\\StatsModel')); $controller->setApplication($container->get(JoomlaApplication\AbstractApplication::class)); $controller->setInput($container->get(Input::class)); return $controller; }, true); $container->share(SubmitControllerGet::class, function (Container $container) { $controller = new SubmitControllerGet(); $controller->setApplication($container->get(JoomlaApplication\AbstractApplication::class)); $controller->setInput($container->get(Input::class)); return $controller; }, true); $container->share(StatsModel::class, function (Container $container) { return new StatsModel($container->get(DatabaseDriver::class)); }, true); $container->share(StatsJsonView::class, function (Container $container) { return new StatsJsonView($container->get(StatsModel::class)); }, true); }