From a7f61b91b7feec80cd9d544502aef937f036ae7c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:45:58 +0200 Subject: [feature/dic] Use DIC in download/file and install/index PHPBB3-10739 --- phpBB/install/index.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 13ab30a9fa..36c10c3ca6 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -79,19 +79,27 @@ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx); -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); +$container = new ContainerBuilder(); +$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); +$loader->load('parameters.yml'); +$loader->load('services.yml'); + +$container->setParameter('core.root_path', $phpbb_root_path); +$container->setParameter('core.php_ext', $phpEx); +$container->setAlias('cache.driver.install', 'cache.driver'); + +$phpbb_class_loader_ext = $container->get('class_loader.ext'); $phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); +$phpbb_class_loader = $container->get('class_loader'); $phpbb_class_loader->register(); // set up caching -$cache_factory = new phpbb_cache_factory('file'); -$cache = $cache_factory->get_service(); -$phpbb_class_loader_ext->set_cache($cache->get_driver()); -$phpbb_class_loader->set_cache($cache->get_driver()); +$cache = $container->get('cache'); +$phpbb_class_loader_ext->set_cache($container->get('cache.driver')); +$phpbb_class_loader->set_cache($container->get('cache.driver')); -$phpbb_dispatcher = new phpbb_event_dispatcher(); -$request = new phpbb_request(); +$phpbb_dispatcher = $container->get('dispatcher'); +$request = $container->get('request'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -- cgit v1.2.1 From dc9ccc432cd0b24cf762f8285d8a90f52b8efe5b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 21:20:58 +0200 Subject: [feature/dic] Make use of calls to cut down on boilerplate PHPBB3-10739 --- phpBB/install/index.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 36c10c3ca6..0d7a0a288c 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -88,15 +88,11 @@ $container->setParameter('core.root_path', $phpbb_root_path); $container->setParameter('core.php_ext', $phpEx); $container->setAlias('cache.driver.install', 'cache.driver'); -$phpbb_class_loader_ext = $container->get('class_loader.ext'); -$phpbb_class_loader_ext->register(); $phpbb_class_loader = $container->get('class_loader'); -$phpbb_class_loader->register(); +$phpbb_class_loader_ext = $container->get('class_loader.ext'); // set up caching $cache = $container->get('cache'); -$phpbb_class_loader_ext->set_cache($container->get('cache.driver')); -$phpbb_class_loader->set_cache($container->get('cache.driver')); $phpbb_dispatcher = $container->get('dispatcher'); $request = $container->get('request'); -- cgit v1.2.1 From 2e76620c8824da62f97cfdaee8f9b1014159fd7c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 00:22:55 +0200 Subject: [feature/dic] Rewrite cron system to use DIC PHPBB3-10739 --- phpBB/install/index.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 0d7a0a288c..dd84e2d519 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -79,23 +79,24 @@ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx); -$container = new ContainerBuilder(); -$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); +$phpbb_container = new ContainerBuilder(); +$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); $loader->load('parameters.yml'); $loader->load('services.yml'); -$container->setParameter('core.root_path', $phpbb_root_path); -$container->setParameter('core.php_ext', $phpEx); -$container->setAlias('cache.driver.install', 'cache.driver'); +$phpbb_container->setParameter('core.root_path', $phpbb_root_path); +$phpbb_container->setParameter('core.php_ext', $phpEx); +$phpbb_container->setAlias('cache.driver.install', 'cache.driver'); +$phpbb_container->set('container', $phpbb_container); -$phpbb_class_loader = $container->get('class_loader'); -$phpbb_class_loader_ext = $container->get('class_loader.ext'); +$phpbb_class_loader = $phpbb_container->get('class_loader'); +$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); // set up caching -$cache = $container->get('cache'); +$cache = $phpbb_container->get('cache'); -$phpbb_dispatcher = $container->get('dispatcher'); -$request = $container->get('request'); +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -- cgit v1.2.1 From 32d2ee61f78e3aeaac5f4f1bcb672c67aa10b10e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 16:14:21 +0200 Subject: [feature/dic] Configure container via config.php, use compiler pass PHPBB3-10739 --- phpBB/install/index.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 88745b8bb9..3e14b719e8 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -7,6 +7,11 @@ * */ +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\Compiler\Compiler; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + /**#@+ * @ignore */ @@ -71,6 +76,8 @@ else // Include essential scripts require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'includes/di/compiler/config_pass.' . $phpEx); + require($phpbb_root_path . 'includes/functions.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); @@ -81,13 +88,13 @@ require($phpbb_root_path . 'includes/functions_install.' . $phpEx); $phpbb_container = new ContainerBuilder(); $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); -$loader->load('parameters.yml'); $loader->load('services.yml'); -$phpbb_container->setParameter('core.root_path', $phpbb_root_path); -$phpbb_container->setParameter('core.php_ext', $phpEx); +$phpbb_compiler = new Compiler(); +$phpbb_compiler->addPass(new phpbb_di_compiler_config_pass($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx)); +$phpbb_compiler->compile($phpbb_container); + $phpbb_container->setAlias('cache.driver.install', 'cache.driver'); -$phpbb_container->set('container', $phpbb_container); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); -- cgit v1.2.1 From 967cc550ed9bb74480f46212768502627f26d62d Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 20:42:07 +0200 Subject: [feature/dic] Introduce DI processors instead of abusing compiler passes PHPBB3-10739 --- phpBB/install/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 3e14b719e8..0e298c8cdc 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -76,7 +76,8 @@ else // Include essential scripts require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/di/compiler/config_pass.' . $phpEx); +require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); +require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); @@ -90,9 +91,8 @@ $phpbb_container = new ContainerBuilder(); $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); $loader->load('services.yml'); -$phpbb_compiler = new Compiler(); -$phpbb_compiler->addPass(new phpbb_di_compiler_config_pass($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx)); -$phpbb_compiler->compile($phpbb_container); +$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); +$processor->process($phpbb_container); $phpbb_container->setAlias('cache.driver.install', 'cache.driver'); -- cgit v1.2.1 From 50bc453aa6c91ae9c9df5cb633615825c9df7b6d Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 21:02:55 +0200 Subject: [feature/dic] Load services from extensions PHPBB3-10739 --- phpBB/install/index.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/install') diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 0e298c8cdc..1ba0798abc 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -8,7 +8,6 @@ */ use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\Compiler\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; @@ -99,6 +98,12 @@ $phpbb_container->setAlias('cache.driver.install', 'cache.driver'); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); +$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); +foreach ($ids as $id) { + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); +} + // set up caching $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From ed34451d5b84f2e34004f2ddbceb6b0ca5cae025 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 26 Jul 2012 17:01:55 +0200 Subject: [feature/dic] Adjust installer script to work with partially configured container PHPBB3-10739 --- phpBB/install/index.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 1ba0798abc..3c1d60f554 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -90,20 +90,14 @@ $phpbb_container = new ContainerBuilder(); $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); $loader->load('services.yml'); -$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); -$processor->process($phpbb_container); +$phpbb_container->setParameter('core.root_path', $phpbb_root_path); +$phpbb_container->setParameter('core.php_ext', $phpEx); -$phpbb_container->setAlias('cache.driver.install', 'cache.driver'); +$phpbb_container->setAlias('cache.driver', 'cache.driver.install'); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) { - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // set up caching $cache = $phpbb_container->get('cache'); -- cgit v1.2.1