aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/common.php43
-rw-r--r--phpBB/composer.json5
-rw-r--r--phpBB/composer.lock16
-rw-r--r--phpBB/config/parameters.yml11
-rw-r--r--phpBB/config/services.yml87
5 files changed, 138 insertions, 24 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index b3b8d7e4f7..aa6115fe1c 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -15,6 +15,9 @@ if (!defined('IN_PHPBB'))
exit;
}
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\EventDispatcher\EventDispatcher;
require($phpbb_root_path . 'includes/startup.' . $phpEx);
@@ -91,43 +94,41 @@ $phpbb_class_loader_ext->register();
$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
$phpbb_class_loader->register();
+$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);
+
// set up caching
-$cache_factory = new phpbb_cache_factory($acm_type);
-$cache = $cache_factory->get_service();
+$cache = $container->get('cache');
$phpbb_class_loader_ext->set_cache($cache->get_driver());
$phpbb_class_loader->set_cache($cache->get_driver());
// Instantiate some basic classes
-$phpbb_dispatcher = new phpbb_event_dispatcher();
-$request = new phpbb_request();
-$user = new phpbb_user();
-$auth = new phpbb_auth();
-$db = new $sql_db();
+$phpbb_dispatcher = $container->get('dispatcher');
+$request = $container->get('request');
+$user = $container->get('user');
+$auth = $container->get('auth');
+$db = $container->get('dbal.conn');
// make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function
-// Connect to DB
-$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
-
-// We do not need this any longer, unset for safety purposes
-unset($dbpasswd);
-
// Grab global variables, re-cache if necessary
-$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
+$config = $container->get('config');
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
// load extensions
-$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
+$phpbb_extension_manager = $container->get('ext.manager');
-// Initialize style
-$phpbb_style_resource_locator = new phpbb_style_resource_locator();
-$phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
-$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider);
-$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template);
+$template = $container->get('template');
+$style = $container->get('style');
-$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager);
+$phpbb_subscriber_loader = $container->get('event.subscriber_loader');
$phpbb_subscriber_loader->load();
// Add own hook handler
diff --git a/phpBB/composer.json b/phpBB/composer.json
index 1059b97f84..56fb2454d1 100644
--- a/phpBB/composer.json
+++ b/phpBB/composer.json
@@ -1,5 +1,8 @@
{
"require": {
- "symfony/event-dispatcher": "2.0.*"
+ "symfony/config": "2.0.*",
+ "symfony/dependency-injection": "2.0.*",
+ "symfony/event-dispatcher": "2.0.*",
+ "symfony/yaml": "2.0.*"
}
}
diff --git a/phpBB/composer.lock b/phpBB/composer.lock
index 062ad4b3aa..1707524da1 100644
--- a/phpBB/composer.lock
+++ b/phpBB/composer.lock
@@ -1,9 +1,21 @@
{
- "hash": "9bada3748ec2933fe0864dcfafbcd671",
+ "hash": "b1e9c3bcfcee0c5630742abb3e49685f",
"packages": [
{
+ "package": "symfony/config",
+ "version": "v2.0.12"
+ },
+ {
+ "package": "symfony/dependency-injection",
+ "version": "v2.0.12"
+ },
+ {
"package": "symfony/event-dispatcher",
- "version": "v2.0.10"
+ "version": "v2.0.12"
+ },
+ {
+ "package": "symfony/yaml",
+ "version": "v2.0.12"
}
],
"aliases": []
diff --git a/phpBB/config/parameters.yml b/phpBB/config/parameters.yml
new file mode 100644
index 0000000000..8a90c8e99d
--- /dev/null
+++ b/phpBB/config/parameters.yml
@@ -0,0 +1,11 @@
+parameters:
+ cache.acm_type: file
+ dbal.driver: dbal_mysqli
+ dbal.dbhost:
+ dbal.dbuser: root
+ dbal.dbpasswd:
+ dbal.dbname: phpbb_dev
+ dbal.dbport:
+ dbal.new_link: false
+ tables.config: phpbb_config
+ tables.ext: phpbb_ext
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
new file mode 100644
index 0000000000..2bf8478f82
--- /dev/null
+++ b/phpBB/config/services.yml
@@ -0,0 +1,87 @@
+services:
+ cache_factory:
+ class: phpbb_cache_factory
+ arguments:
+ - %cache.acm_type%
+
+ cache:
+ class: phpbb_cache_service
+ factory_service: cache_factory
+ factory_method: get_service
+
+ cache.driver:
+ class: phpbb_cache_driver_interface
+ factory_service: cache
+ factory_method: get_driver
+
+ dispatcher:
+ class: phpbb_event_dispatcher
+
+ request:
+ class: phpbb_request
+
+ user:
+ class: phpbb_user
+
+ auth:
+ class: phpbb_auth
+
+ dbal.conn:
+ class: %dbal.driver%
+ calls:
+ - [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]]
+
+ config:
+ class: phpbb_config_db
+ arguments:
+ - @dbal.conn
+ - @cache.driver
+ - %tables.config%
+
+ ext.manager:
+ class: phpbb_extension_manager
+ arguments:
+ - @dbal.conn
+ - %tables.ext%
+ - %core.root_path%
+ - .%core.php_ext%
+ - @cache.driver
+
+ style.resource_locator:
+ class: phpbb_style_resource_locator
+
+ style.path_provider_ext:
+ class: phpbb_style_extension_path_provider
+ arguments:
+ - @ext.manager
+ - @style.path_provider
+
+ style.path_provider:
+ class: phpbb_style_path_provider
+
+ template:
+ class: phpbb_style_template
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ - @user
+ - @style.resource_locator
+ - @style.path_provider_ext
+
+ style:
+ class: phpbb_style
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ - @user
+ - @style.resource_locator
+ - @style.path_provider_ext
+ - @template
+
+ event.subscriber_loader:
+ class: phpbb_event_extension_subscriber_loader
+ arguments:
+ - @dispatcher
+ - @ext.manager