aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2012-11-12 10:46:21 +0100
committerIgor Wiedler <igor@wiedler.ch>2012-11-12 10:46:21 +0100
commitbf641a7f31f87eb7b88437214315872bff36ae84 (patch)
tree6e850dff6caf7e939ee614a1dbeb5ba4f1deb002
parent9bc9ac281af9f194d73160ae3545105f24db5395 (diff)
parent5a5e507a14084b08e41c4d2f86f2fb6700e68eb5 (diff)
downloadforums-bf641a7f31f87eb7b88437214315872bff36ae84.tar
forums-bf641a7f31f87eb7b88437214315872bff36ae84.tar.gz
forums-bf641a7f31f87eb7b88437214315872bff36ae84.tar.bz2
forums-bf641a7f31f87eb7b88437214315872bff36ae84.tar.xz
forums-bf641a7f31f87eb7b88437214315872bff36ae84.zip
Merge remote-tracking branch 'upstream/develop' into ticket/11015
* upstream/develop: (31 commits) [ticket/11194] Service tag data is stored in an array so access it correctly [ticket/11193] Instantiate a single collection_pass for all collections [ticket/11152] Basic tests for the container functions [ticket/11152] Compile the install container [ticket/11152] Throw error if services.yml is missing [ticket/11152] Remove old container processor calls [ticket/11152] Use realpath in container extensions consistently [ticket/11152] Rename collection to collection_pass [ticket/11152] Remove @api docblocks [ticket/11152] Create separate function for debug-dependent container [ticket/11152] Change phpbb_di_pass_cron to generic phpbb_di_pass_collection [ticket/11152] Convert cron_task_collection to generic di_service_collection [ticket/11152] Use relative root path in container, one dumped container per path [ticket/11152] Move container functions to a separate function file [feature/compiled-dic] Rename $phpEx to $php_ext in new code [feature/compiled-dic] Use an absolute path for core.root_path parameter [feature/compiled-dic] Update the composer.lock file [feature/compiled-dic] Purge cache to make ext services available right away [feature/compiled-dic] Fix root path when container is created after install [feature/compiled-dic] Remove old test ...
-rw-r--r--phpBB/common.php39
-rw-r--r--phpBB/composer.json1
-rw-r--r--phpBB/composer.lock750
-rw-r--r--phpBB/config/services.yml19
-rw-r--r--phpBB/download/file.php38
-rw-r--r--phpBB/includes/cache/driver/file.php6
-rw-r--r--phpBB/includes/cache/driver/memory.php6
-rw-r--r--phpBB/includes/cron/task/provider.php59
-rw-r--r--phpBB/includes/di/extension/config.php (renamed from phpBB/includes/di/processor/config.php)55
-rw-r--r--phpBB/includes/di/extension/core.php69
-rw-r--r--phpBB/includes/di/extension/ext.php69
-rw-r--r--phpBB/includes/di/pass/collection_pass.php46
-rw-r--r--phpBB/includes/di/processor/ext.php54
-rw-r--r--phpBB/includes/di/processor/interface.php28
-rw-r--r--phpBB/includes/di/service_collection.php49
-rw-r--r--phpBB/includes/event/dispatcher.php4
-rw-r--r--phpBB/includes/extension/controller.php84
-rw-r--r--phpBB/includes/extension/controller_interface.php31
-rw-r--r--phpBB/includes/extension/manager.php10
-rw-r--r--phpBB/includes/functions_container.php140
-rw-r--r--phpBB/install/database_update.php34
-rw-r--r--phpBB/install/index.php21
-rw-r--r--tests/cron/task_provider_test.php50
-rw-r--r--tests/di/create_container_test.php72
-rw-r--r--tests/di/fixtures/config.php11
-rw-r--r--tests/event/dispatcher_test.php2
-rw-r--r--tests/mock/container_builder.php160
27 files changed, 1464 insertions, 443 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 72b938a5bf..ffae88d0d4 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -69,11 +69,10 @@ if (!defined('PHPBB_INSTALLED'))
// Include files
require($phpbb_root_path . 'includes/class_loader.' . $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);
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
+require($phpbb_root_path . 'includes/functions_container.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
@@ -81,16 +80,27 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Set PHP error handler to ours
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
-$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);
-
// Setup class loader first
-$phpbb_class_loader = $phpbb_container->get('class_loader');
-$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
+$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx");
+$phpbb_class_loader->register();
+$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx");
+$phpbb_class_loader_ext->register();
+
+// Set up container
+$phpbb_container = phpbb_create_dumped_container_unless_debug(
+ array(
+ new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx),
+ new phpbb_di_extension_core($phpbb_root_path),
+ ),
+ array(
+ new phpbb_di_pass_collection_pass(),
+ ),
+ $phpbb_root_path,
+ $phpEx
+);
+
+$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
+$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
// set up caching
$cache = $phpbb_container->get('cache');
@@ -117,13 +127,6 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
$template = $phpbb_container->get('template');
$phpbb_style = $phpbb_container->get('style');
-$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
-foreach ($ids as $id)
-{
- $processor = $phpbb_container->get($id);
- $processor->process($phpbb_container);
-}
-
// Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display')));
diff --git a/phpBB/composer.json b/phpBB/composer.json
index 5e88144bc4..380bdc367c 100644
--- a/phpBB/composer.json
+++ b/phpBB/composer.json
@@ -4,6 +4,7 @@
"symfony/config": "2.1.*",
"symfony/dependency-injection": "2.1.*",
"symfony/event-dispatcher": "2.1.*",
+ "symfony/http-kernel": "2.1.*",
"symfony/yaml": "2.1.*"
},
"require-dev": {
diff --git a/phpBB/composer.lock b/phpBB/composer.lock
index 6b0d3584d1..69e4a2b4b8 100644
--- a/phpBB/composer.lock
+++ b/phpBB/composer.lock
@@ -1,67 +1,749 @@
{
- "hash": "1632798bc1d5298a4f5bd3087c972a9f",
+ "hash": "407cc89f4bb0e409146c863dee51b0ae",
"packages": [
{
- "package": "symfony/config",
- "version": "v2.1.0-RC1"
+ "name": "symfony/config",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/Config",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Config",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/Config/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "time": "2012-10-20 00:10:30",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Config": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Config Component",
+ "homepage": "http://symfony.com"
},
{
- "package": "symfony/dependency-injection",
- "version": "v2.1.0-RC1"
+ "name": "symfony/dependency-injection",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/DependencyInjection",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/DependencyInjection",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/DependencyInjection/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "symfony/yaml": "2.1.*",
+ "symfony/config": "2.1.*"
+ },
+ "suggest": {
+ "symfony/yaml": "2.1.*",
+ "symfony/config": "2.1.*"
+ },
+ "time": "2012-10-22 07:37:12",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\DependencyInjection": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony DependencyInjection Component",
+ "homepage": "http://symfony.com"
},
{
- "package": "symfony/event-dispatcher",
- "version": "v2.1.0-RC1"
+ "name": "symfony/event-dispatcher",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/EventDispatcher",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/EventDispatcher",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/EventDispatcher/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "symfony/dependency-injection": "2.1.*"
+ },
+ "suggest": {
+ "symfony/dependency-injection": "2.1.*",
+ "symfony/http-kernel": "2.1.*"
+ },
+ "time": "2012-10-04 08:17:57",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\EventDispatcher": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony EventDispatcher Component",
+ "homepage": "http://symfony.com"
},
{
- "package": "symfony/yaml",
- "version": "v2.1.0-RC1"
+ "name": "symfony/http-foundation",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/HttpFoundation",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/HttpFoundation",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/HttpFoundation/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "time": "2012-10-20 00:10:30",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\HttpFoundation": "",
+ "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs"
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony HttpFoundation Component",
+ "homepage": "http://symfony.com"
+ },
+ {
+ "name": "symfony/http-kernel",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/HttpKernel",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/HttpKernel",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/HttpKernel/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "symfony/event-dispatcher": "2.1.*",
+ "symfony/http-foundation": "2.1.*"
+ },
+ "require-dev": {
+ "symfony/browser-kit": "2.1.*",
+ "symfony/class-loader": "2.1.*",
+ "symfony/config": "2.1.*",
+ "symfony/console": "2.1.*",
+ "symfony/dependency-injection": "2.1.*",
+ "symfony/finder": "2.1.*",
+ "symfony/process": "2.1.*",
+ "symfony/routing": "2.1.*"
+ },
+ "suggest": {
+ "symfony/browser-kit": "2.1.*",
+ "symfony/class-loader": "2.1.*",
+ "symfony/config": "2.1.*",
+ "symfony/console": "2.1.*",
+ "symfony/dependency-injection": "2.1.*",
+ "symfony/finder": "2.1.*"
+ },
+ "time": "2012-10-30 01:14:14",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\HttpKernel": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony HttpKernel Component",
+ "homepage": "http://symfony.com"
+ },
+ {
+ "name": "symfony/yaml",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/Yaml",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Yaml",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/Yaml/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "time": "2012-10-29 04:15:41",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Yaml": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Yaml Component",
+ "homepage": "http://symfony.com"
}
],
"packages-dev": [
{
- "package": "fabpot/goutte",
- "version": "dev-master",
- "alias-pretty-version": "1.0.x-dev",
- "alias-version": "1.0.9999999.9999999-dev"
- },
- {
- "package": "fabpot/goutte",
+ "name": "fabpot/goutte",
"version": "dev-master",
- "source-reference": "6d26279344736f6983a969e46afef082ebf30a67",
- "commit-date": "1345141401"
+ "source": {
+ "type": "git",
+ "url": "https://github.com/fabpot/Goutte",
+ "reference": "f2940f9c7c1f409159f5e9f512e575946c5cff48"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/fabpot/Goutte/zipball/f2940f9c7c1f409159f5e9f512e575946c5cff48",
+ "reference": "f2940f9c7c1f409159f5e9f512e575946c5cff48",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0",
+ "symfony/browser-kit": "2.1.*",
+ "symfony/css-selector": "2.1.*",
+ "symfony/dom-crawler": "2.1.*",
+ "symfony/finder": "2.1.*",
+ "symfony/process": "2.1.*",
+ "ext-curl": "*",
+ "guzzle/http": "2.8.*"
+ },
+ "time": "1351086217",
+ "type": "application",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "installation-source": "source",
+ "autoload": {
+ "psr-0": {
+ "Goutte": "."
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "A simple PHP Web Scraper",
+ "homepage": "https://github.com/fabpot/Goutte",
+ "keywords": [
+ "scraper"
+ ]
},
{
- "package": "guzzle/common",
- "version": "v2.8.4"
+ "name": "guzzle/common",
+ "version": "v2.8.8",
+ "target-dir": "Guzzle/Common",
+ "source": {
+ "type": "git",
+ "url": "git://github.com/guzzle/common.git",
+ "reference": "v2.8.8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/guzzle/common/zipball/v2.8.8",
+ "reference": "v2.8.8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2",
+ "symfony/event-dispatcher": "2.1.*"
+ },
+ "time": "2012-10-15 17:42:47",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Guzzle\\Common": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "description": "Common libraries used by Guzzle",
+ "homepage": "http://guzzlephp.org/",
+ "keywords": [
+ "log",
+ "event",
+ "cache",
+ "validation",
+ "Socket",
+ "common",
+ "batch",
+ "inflection"
+ ]
},
{
- "package": "guzzle/http",
- "version": "v2.8.4"
+ "name": "guzzle/http",
+ "version": "v2.8.8",
+ "target-dir": "Guzzle/Http",
+ "source": {
+ "type": "git",
+ "url": "git://github.com/guzzle/http.git",
+ "reference": "v2.8.8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/guzzle/http/zipball/v2.8.8",
+ "reference": "v2.8.8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2",
+ "guzzle/common": "self.version",
+ "guzzle/parser": "self.version"
+ },
+ "time": "2012-10-15 17:42:47",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Guzzle\\Http": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "description": "HTTP libraries used by Guzzle",
+ "homepage": "http://guzzlephp.org/",
+ "keywords": [
+ "curl",
+ "http",
+ "http client",
+ "client",
+ "Guzzle"
+ ]
},
{
- "package": "guzzle/parser",
- "version": "v2.8.4"
+ "name": "guzzle/parser",
+ "version": "v2.8.8",
+ "target-dir": "Guzzle/Parser",
+ "source": {
+ "type": "git",
+ "url": "git://github.com/guzzle/parser.git",
+ "reference": "v2.8.8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/guzzle/parser/zipball/v2.8.8",
+ "reference": "v2.8.8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "time": "2012-09-20 13:28:06",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Guzzle\\Parser": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "description": "Interchangeable parsers used by Guzzle",
+ "homepage": "http://guzzlephp.org/",
+ "keywords": [
+ "http",
+ "url",
+ "message",
+ "cookie",
+ "URI Template"
+ ]
},
{
- "package": "symfony/browser-kit",
- "version": "v2.1.0-RC1"
+ "name": "symfony/browser-kit",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/BrowserKit",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/BrowserKit",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/BrowserKit/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "symfony/dom-crawler": "2.1.*"
+ },
+ "require-dev": {
+ "symfony/process": "2.1.*",
+ "symfony/css-selector": "2.1.*"
+ },
+ "suggest": {
+ "symfony/process": "2.1.*"
+ },
+ "time": "2012-10-25 06:11:50",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\BrowserKit": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony BrowserKit Component",
+ "homepage": "http://symfony.com"
},
{
- "package": "symfony/css-selector",
- "version": "v2.1.0-RC1"
+ "name": "symfony/css-selector",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/CssSelector",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/CssSelector",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/CssSelector/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "time": "2012-10-04 08:17:57",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\CssSelector": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony CssSelector Component",
+ "homepage": "http://symfony.com"
},
{
- "package": "symfony/dom-crawler",
- "version": "v2.1.0-RC1"
+ "name": "symfony/dom-crawler",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/DomCrawler",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/DomCrawler",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/DomCrawler/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "symfony/css-selector": "2.1.*"
+ },
+ "suggest": {
+ "symfony/css-selector": "2.1.*"
+ },
+ "time": "2012-10-18 14:16:01",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\DomCrawler": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony DomCrawler Component",
+ "homepage": "http://symfony.com"
},
{
- "package": "symfony/finder",
- "version": "v2.1.0-RC1"
+ "name": "symfony/finder",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/Finder",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Finder",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/Finder/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "time": "2012-10-20 00:10:30",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Finder": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Finder Component",
+ "homepage": "http://symfony.com"
},
{
- "package": "symfony/process",
- "version": "v2.1.0-RC1"
+ "name": "symfony/process",
+ "version": "v2.1.3",
+ "target-dir": "Symfony/Component/Process",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Process",
+ "reference": "v2.1.3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/Process/zipball/v2.1.3",
+ "reference": "v2.1.3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "time": "2012-10-20 00:10:30",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Process": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Process Component",
+ "homepage": "http://symfony.com"
}
],
"aliases": [
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 038c8a862d..20aa0546d5 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -44,15 +44,17 @@ services:
- @cache.driver
- %tables.config%
- cron.task_provider:
- class: phpbb_cron_task_provider
+ cron.task_collection:
+ class: phpbb_di_service_collection
arguments:
- - @container
+ - @service_container
+ tags:
+ - { name: service_collection, tag: cron.task }
cron.manager:
class: phpbb_cron_manager
arguments:
- - @cron.task_provider
+ - @cron.task_collection
- %core.root_path%
- %core.php_ext%
@@ -65,6 +67,8 @@ services:
dispatcher:
class: phpbb_event_dispatcher
+ arguments:
+ - @service_container
dbal.conn:
class: %dbal.driver.class%
@@ -89,13 +93,6 @@ services:
- .%core.php_ext%
- @cache.driver
- processor.ext:
- class: phpbb_di_processor_ext
- arguments:
- - @ext.manager
- tags:
- - { name: container.processor }
-
request:
class: phpbb_request
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index b581af7ce3..1168a943af 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -45,18 +45,31 @@ if (isset($_GET['avatar']))
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx);
+ require($phpbb_root_path . 'includes/functions_container.' . $phpEx);
require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
- $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_class_loader = $phpbb_container->get('class_loader');
- $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
+ // Setup class loader first
+ $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx");
+ $phpbb_class_loader->register();
+ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx");
+ $phpbb_class_loader_ext->register();
+
+ // Set up container
+ $phpbb_container = phpbb_create_dumped_container_unless_debug(
+ array(
+ new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx),
+ new phpbb_di_extension_core($phpbb_root_path),
+ ),
+ array(
+ new phpbb_di_pass_collection_pass(),
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
+ $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
// set up caching
$cache = $phpbb_container->get('cache');
@@ -82,13 +95,6 @@ if (isset($_GET['avatar']))
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
- $ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
- foreach ($ids as $id)
- {
- $processor = $phpbb_container->get($id);
- $processor->process($phpbb_container);
- }
-
// worst-case default
$browser = strtolower($request->header('User-Agent', 'msie 6.0'));
diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php
index ced45b29ea..23063a1a28 100644
--- a/phpBB/includes/cache/driver/file.php
+++ b/phpBB/includes/cache/driver/file.php
@@ -214,7 +214,11 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
while (($entry = readdir($dir)) !== false)
{
- if (strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0)
+ if (strpos($entry, 'container') !== 0 &&
+ strpos($entry, 'sql_') !== 0 &&
+ strpos($entry, 'data_') !== 0 &&
+ strpos($entry, 'ctpl_') !== 0 &&
+ strpos($entry, 'tpl_') !== 0)
{
continue;
}
diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php
index 6142b6f65d..623ae44144 100644
--- a/phpBB/includes/cache/driver/memory.php
+++ b/phpBB/includes/cache/driver/memory.php
@@ -162,7 +162,11 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base
while (($entry = readdir($dir)) !== false)
{
- if (strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0)
+ if (strpos($entry, 'container') !== 0 &&
+ strpos($entry, 'sql_') !== 0 &&
+ strpos($entry, 'data_') !== 0 &&
+ strpos($entry, 'ctpl_') !== 0 &&
+ strpos($entry, 'tpl_') !== 0)
{
continue;
}
diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php
deleted file mode 100644
index 134723ebd1..0000000000
--- a/phpBB/includes/cron/task/provider.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
-*
-* @package phpBB3
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-use Symfony\Component\DependencyInjection\TaggedContainerInterface;
-
-/**
-* Provides cron manager with tasks
-*
-* Finds installed cron tasks and makes them available to the cron manager.
-*
-* @package phpBB3
-*/
-class phpbb_cron_task_provider implements IteratorAggregate
-{
- private $container;
-
- public function __construct(TaggedContainerInterface $container)
- {
- $this->container = $container;
- }
-
- /**
- * Retrieve an iterator over all items
- *
- * @return ArrayIterator An iterator for the array of cron tasks
- */
- public function getIterator()
- {
- $definitions = $this->container->findTaggedServiceIds('cron.task');
-
- $tasks = array();
- foreach ($definitions as $name => $definition)
- {
- $task = $this->container->get($name);
- if ($task instanceof phpbb_cron_task_base)
- {
- $task->set_name($name);
- }
-
- $tasks[] = $task;
- }
-
- return new ArrayIterator($tasks);
- }
-}
diff --git a/phpBB/includes/di/processor/config.php b/phpBB/includes/di/extension/config.php
index 2abb1c1c33..5b2df93ff2 100644
--- a/phpBB/includes/di/processor/config.php
+++ b/phpBB/includes/di/extension/config.php
@@ -16,40 +16,31 @@ if (!defined('IN_PHPBB'))
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\Config\FileLocator;
/**
-* Configure the container for phpBB's services though
-* user-defined parameters defined in the config.php file.
+* Container config extension
*/
-class phpbb_di_processor_config implements phpbb_di_processor_interface
+class phpbb_di_extension_config extends Extension
{
- private $config_file;
- private $phpbb_root_path;
- private $php_ext;
-
- /**
- * Constructor.
- *
- * @param string $config_file The config file
- * @param string $phpbb_root_path The root path
- * @param string $php_ext The PHP extension
- */
- public function __construct($config_file, $phpbb_root_path, $php_ext)
+ public function __construct($config_file)
{
$this->config_file = $config_file;
- $this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = $php_ext;
}
/**
- * @inheritdoc
+ * Loads a specific configuration.
+ *
+ * @param array $config An array of configuration values
+ * @param ContainerBuilder $container A ContainerBuilder instance
+ *
+ * @throws InvalidArgumentException When provided tag is not defined in this extension
*/
- public function process(ContainerBuilder $container)
+ public function load(array $config, ContainerBuilder $container)
{
- require $this->config_file;
-
- $container->setParameter('core.root_path', $this->phpbb_root_path);
- $container->setParameter('core.php_ext', $this->php_ext);
+ require($this->config_file);
$container->setParameter('core.table_prefix', $table_prefix);
$container->setParameter('cache.driver.class', $this->fix_acm_type($acm_type));
@@ -60,10 +51,26 @@ class phpbb_di_processor_config implements phpbb_di_processor_interface
$container->setParameter('dbal.dbname', $dbname);
$container->setParameter('dbal.dbport', $dbport);
$container->setParameter('dbal.new_link', defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK);
+ }
- $container->set('container', $container);
+ /**
+ * Returns the recommended alias to use in XML.
+ *
+ * This alias is also the mandatory prefix to use when using YAML.
+ *
+ * @return string The alias
+ */
+ public function getAlias()
+ {
+ return 'config';
}
+ /**
+ * Convert old (3.0) values to 3.1 class names
+ *
+ * @param style $acm_type ACM type
+ * @return ACM type class
+ */
protected function fix_acm_type($acm_type)
{
if (preg_match('#^[a-z]+$#', $acm_type))
diff --git a/phpBB/includes/di/extension/core.php b/phpBB/includes/di/extension/core.php
new file mode 100644
index 0000000000..9c36ba2fc4
--- /dev/null
+++ b/phpBB/includes/di/extension/core.php
@@ -0,0 +1,69 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\Config\FileLocator;
+
+/**
+* Container core extension
+*/
+class phpbb_di_extension_core extends Extension
+{
+ /**
+ * phpBB Root path
+ * @var string
+ */
+ protected $root_path;
+
+ /**
+ * Constructor
+ *
+ * @param string $root_path Root path
+ */
+ public function __construct($root_path)
+ {
+ $this->root_path = $root_path;
+ }
+
+ /**
+ * Loads a specific configuration.
+ *
+ * @param array $config An array of configuration values
+ * @param ContainerBuilder $container A ContainerBuilder instance
+ *
+ * @throws InvalidArgumentException When provided tag is not defined in this extension
+ */
+ public function load(array $config, ContainerBuilder $container)
+ {
+ $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'config')));
+ $loader->load('services.yml');
+ }
+
+ /**
+ * Returns the recommended alias to use in XML.
+ *
+ * This alias is also the mandatory prefix to use when using YAML.
+ *
+ * @return string The alias
+ */
+ public function getAlias()
+ {
+ return 'core';
+ }
+}
diff --git a/phpBB/includes/di/extension/ext.php b/phpBB/includes/di/extension/ext.php
new file mode 100644
index 0000000000..e76c543ee1
--- /dev/null
+++ b/phpBB/includes/di/extension/ext.php
@@ -0,0 +1,69 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\Config\FileLocator;
+
+/**
+* Container ext extension
+*/
+class phpbb_di_extension_ext extends Extension
+{
+ protected $paths = array();
+
+ public function __construct($enabled_extensions)
+ {
+ foreach ($enabled_extensions as $ext => $path)
+ {
+ $this->paths[] = $path;
+ }
+ }
+
+ /**
+ * Loads a specific configuration.
+ *
+ * @param array $config An array of configuration values
+ * @param ContainerBuilder $container A ContainerBuilder instance
+ *
+ * @throws InvalidArgumentException When provided tag is not defined in this extension
+ */
+ public function load(array $config, ContainerBuilder $container)
+ {
+ foreach ($this->paths as $path)
+ {
+ if (file_exists($path . '/config/services.yml'))
+ {
+ $loader = new YamlFileLoader($container, new FileLocator(phpbb_real_path($path . '/config')));
+ $loader->load('services.yml');
+ }
+ }
+ }
+
+ /**
+ * Returns the recommended alias to use in XML.
+ *
+ * This alias is also the mandatory prefix to use when using YAML.
+ *
+ * @return string The alias
+ */
+ public function getAlias()
+ {
+ return 'ext';
+ }
+}
diff --git a/phpBB/includes/di/pass/collection_pass.php b/phpBB/includes/di/pass/collection_pass.php
new file mode 100644
index 0000000000..63a5c7dfc4
--- /dev/null
+++ b/phpBB/includes/di/pass/collection_pass.php
@@ -0,0 +1,46 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+
+/**
+* Appends an add method call to the definition of each collection service for
+* the services tagged with the appropriate name defined in the collection's
+* service_collection tag.
+*/
+class phpbb_di_pass_collection_pass implements CompilerPassInterface
+{
+ /**
+ * Modify the container before it is passed to the rest of the code
+ *
+ * @param ContainerBuilder $container ContainerBuilder object
+ * @return null
+ */
+ public function process(ContainerBuilder $container)
+ {
+ foreach ($container->findTaggedServiceIds('service_collection') as $id => $data)
+ {
+ $definition = $container->getDefinition($id);
+
+ foreach ($container->findTaggedServiceIds($data[0]['tag']) as $service_id => $service_data)
+ {
+ $definition->addMethodCall('add', array($service_id));
+ }
+ }
+ }
+}
diff --git a/phpBB/includes/di/processor/ext.php b/phpBB/includes/di/processor/ext.php
deleted file mode 100644
index e69a3d73b3..0000000000
--- a/phpBB/includes/di/processor/ext.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
-*
-* @package phpBB3
-* @copyright (c) 2012 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-use Symfony\Component\Config\FileLocator;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
-
-/**
-* Load the service configurations from all extensions into the container.
-*/
-class phpbb_di_processor_ext implements phpbb_di_processor_interface
-{
- private $extension_manager;
-
- /**
- * Constructor.
- *
- * @param string $extension_manager The extension manager
- */
- public function __construct($extension_manager)
- {
- $this->extension_manager = $extension_manager;
- }
-
- /**
- * @inheritdoc
- */
- public function process(ContainerBuilder $container)
- {
- $enabled_exts = $this->extension_manager->all_enabled();
- foreach ($enabled_exts as $name => $path)
- {
- if (file_exists($path . '/config/services.yml'))
- {
- $loader = new YamlFileLoader($container, new FileLocator($path . '/config'));
- $loader->load('services.yml');
- }
- }
- }
-}
diff --git a/phpBB/includes/di/processor/interface.php b/phpBB/includes/di/processor/interface.php
deleted file mode 100644
index b8563791cc..0000000000
--- a/phpBB/includes/di/processor/interface.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
-*
-* @package phpBB3
-* @copyright (c) 2012 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-
-interface phpbb_di_processor_interface
-{
- /**
- * Mutate the container.
- *
- * @param ContainerBuilder $container The container
- */
- public function process(ContainerBuilder $container);
-}
diff --git a/phpBB/includes/di/service_collection.php b/phpBB/includes/di/service_collection.php
new file mode 100644
index 0000000000..60323c8dba
--- /dev/null
+++ b/phpBB/includes/di/service_collection.php
@@ -0,0 +1,49 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+* Collection of services to be configured at container compile time.
+*
+* @package phpBB3
+*/
+class phpbb_di_service_collection extends ArrayObject
+{
+ /**
+ * Constructor
+ *
+ * @param ContainerInterface $container Container object
+ */
+ public function __construct(ContainerInterface $container)
+ {
+ $this->container = $container;
+ }
+
+ /**
+ * Add a service to the collection
+ *
+ * @param string $name The service name
+ * @return null
+ */
+ public function add($name)
+ {
+ $task = $this->container->get($name);
+ $task->set_name($name);
+ $this->offsetSet($name, $task);
+ }
+}
diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php
index 2bf46b9b06..4f637ce3bb 100644
--- a/phpBB/includes/event/dispatcher.php
+++ b/phpBB/includes/event/dispatcher.php
@@ -15,7 +15,7 @@ if (!defined('IN_PHPBB'))
exit;
}
-use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
/**
* Extension of the Symfony2 EventDispatcher
@@ -31,7 +31,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
* extract($phpbb_dispatcher->trigger_event('core.index', compact($vars)));
*
*/
-class phpbb_event_dispatcher extends EventDispatcher
+class phpbb_event_dispatcher extends ContainerAwareEventDispatcher
{
public function trigger_event($eventName, $data = array())
{
diff --git a/phpBB/includes/extension/controller.php b/phpBB/includes/extension/controller.php
deleted file mode 100644
index f97b69c7ed..0000000000
--- a/phpBB/includes/extension/controller.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
-*
-* @package extension
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
-* Abstract class extended by extension front controller classes
-*
-* @package extension
-*/
-abstract class phpbb_extension_controller implements phpbb_extension_controller_interface
-{
- /**
- * Request class object
- * @var phpbb_request
- */
- protected $request;
-
- /**
- * DBAL class object
- * @var dbal
- */
- protected $db;
-
- /**
- * User class object
- * @var phpbb_user
- */
- protected $user;
-
- /**
- * Template class object
- * @var phpbb_template
- */
- protected $template;
-
- /**
- * Config object
- * @var phpbb_config
- */
- protected $config;
-
- /**
- * PHP Extension
- * @var string
- */
- protected $php_ext;
-
- /**
- * Relative path to board root
- * @var string
- */
- protected $phpbb_root_path;
-
- /**
- * Constructor method that provides the common phpBB objects as inherited class
- * properties for automatic availability in extension controllers
- */
- public function __construct()
- {
- global $request, $db, $user, $template, $config;
- global $phpEx, $phpbb_root_path;
-
- $this->request = $request;
- $this->db = $db;
- $this->user = $user;
- $this->template = $template;
- $this->config = $config;
- $this->php_ext = $phpEx;
- $this->phpbb_root_path = $phpbb_root_path;
- }
-}
diff --git a/phpBB/includes/extension/controller_interface.php b/phpBB/includes/extension/controller_interface.php
deleted file mode 100644
index 2b88925388..0000000000
--- a/phpBB/includes/extension/controller_interface.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
-*
-* @package extension
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
-* The interface that extension classes have to implement to run front pages
-*
-* @package extension
-*/
-interface phpbb_extension_controller_interface
-{
- /**
- * Handle the request to display a page from an extension
- *
- * @return null
- */
- public function handle();
-}
diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php
index 55502a610c..862bca1855 100644
--- a/phpBB/includes/extension/manager.php
+++ b/phpBB/includes/extension/manager.php
@@ -195,7 +195,7 @@ class phpbb_extension_manager
if ($this->cache)
{
- $this->cache->destroy($this->cache_name);
+ $this->cache->purge();
}
return !$active;
@@ -252,7 +252,7 @@ class phpbb_extension_manager
if ($this->cache)
{
- $this->cache->destroy($this->cache_name);
+ $this->cache->purge();
}
return true;
@@ -272,7 +272,7 @@ class phpbb_extension_manager
if ($this->cache)
{
- $this->cache->destroy($this->cache_name);
+ $this->cache->purge();
}
return false;
@@ -335,7 +335,7 @@ class phpbb_extension_manager
if ($this->cache)
{
- $this->cache->destroy($this->cache_name);
+ $this->cache->purge();
}
return true;
@@ -349,7 +349,7 @@ class phpbb_extension_manager
if ($this->cache)
{
- $this->cache->destroy($this->cache_name);
+ $this->cache->purge();
}
return false;
diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php
new file mode 100644
index 0000000000..1de1d9f7ea
--- /dev/null
+++ b/phpBB/includes/functions_container.php
@@ -0,0 +1,140 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Create the ContainerBuilder object
+*
+* @param array $extensions Array of Container extension objects
+* @param string $phpbb_root_path Root path
+* @param string $php_ext PHP Extension
+* @return ContainerBuilder object
+*/
+function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext)
+{
+ $container = new ContainerBuilder();
+
+ foreach ($extensions as $extension)
+ {
+ $container->registerExtension($extension);
+ $container->loadFromExtension($extension->getAlias());
+ }
+
+ $container->setParameter('core.root_path', $phpbb_root_path);
+ $container->setParameter('core.php_ext', $php_ext);
+
+ return $container;
+}
+
+/**
+* Create installer container
+*
+* @param string $phpbb_root_path Root path
+* @param string $php_ext PHP Extension
+* @return ContainerBuilder object
+*/
+function phpbb_create_install_container($phpbb_root_path, $php_ext)
+{
+ $core = new phpbb_di_extension_core($phpbb_root_path);
+ $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext);
+
+ $container->setParameter('core.root_path', $phpbb_root_path);
+ $container->setParameter('core.php_ext', $php_ext);
+ $container->setParameter('core.table_prefix', '');
+
+ $container->register('dbal.conn')->setSynthetic(true);
+
+ $container->setAlias('cache.driver', 'cache.driver.install');
+
+ $container->compile();
+
+ return $container;
+}
+
+/**
+* Create a compiled ContainerBuilder object
+*
+* @param array $extensions Array of Container extension objects
+* @param array $passes Array of Compiler Pass objects
+* @param string $phpbb_root_path Root path
+* @param string $php_ext PHP Extension
+* @return ContainerBuilder object (compiled)
+*/
+function phpbb_create_compiled_container(array $extensions, array $passes, $phpbb_root_path, $php_ext)
+{
+ // Create a temporary container for access to the ext.manager service
+ $tmp_container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext);
+ $tmp_container->compile();
+
+ // Now pass the enabled extension paths into the ext compiler extension
+ $extensions[] = new phpbb_di_extension_ext($tmp_container->get('ext.manager')->all_enabled());
+
+ // Create the final container to be compiled and cached
+ $container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext);
+
+ // Compile the container
+ foreach ($passes as $pass)
+ {
+ $container->addCompilerPass($pass);
+ }
+ $container->compile();
+
+ return $container;
+}
+
+function phpbb_create_dumped_container(array $extensions, array $passes, $phpbb_root_path, $php_ext)
+{
+ // Check for our cached container; if it exists, use it
+ $container_filename = phpbb_container_filename($phpbb_root_path, $php_ext);
+ if (file_exists($container_filename))
+ {
+ require($container_filename);
+ return new phpbb_cache_container();
+ }
+
+ $container = phpbb_create_compiled_container($extensions, $passes, $phpbb_root_path, $php_ext);
+
+ // Lastly, we create our cached container class
+ $dumper = new PhpDumper($container);
+ $cached_container_dump = $dumper->dump(array(
+ 'class' => 'phpbb_cache_container',
+ 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
+ ));
+
+ file_put_contents($container_filename, $cached_container_dump);
+
+ return $container;
+}
+
+function phpbb_create_dumped_container_unless_debug(array $extensions, array $passes, $phpbb_root_path, $php_ext)
+{
+ if (defined('DEBUG')) {
+ return phpbb_create_compiled_container($extensions, $passes, $phpbb_root_path, $php_ext);
+ }
+
+ return phpbb_create_dumped_container($extensions, $passes, $phpbb_root_path, $php_ext);
+}
+
+function phpbb_container_filename($phpbb_root_path, $php_ext)
+{
+ $filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path);
+ return $phpbb_root_path . 'cache/' . $filename . '_container.' . $php_ext;
+}
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index eb464f6750..ded9ed00f9 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -77,6 +77,7 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type))
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx);
+require($phpbb_root_path . 'includes/functions_container.' . $phpEx);
phpbb_require_updated('includes/functions_content.' . $phpEx, true);
@@ -97,20 +98,27 @@ if (!defined('EXT_TABLE'))
define('EXT_TABLE', $table_prefix . 'ext');
}
-$phpbb_container = new ContainerBuilder();
-$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
-$loader->load('services.yml');
-
-// We must include the DI processor class files because the class loader
-// is not yet set up
-require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
-require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
-$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx);
-$processor->process($phpbb_container);
-
// Setup class loader first
-$phpbb_class_loader = $phpbb_container->get('class_loader');
-$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
+$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx");
+$phpbb_class_loader->register();
+$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx");
+$phpbb_class_loader_ext->register();
+
+// Set up container
+$phpbb_container = phpbb_create_dumped_container_unless_debug(
+ array(
+ new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx),
+ new phpbb_di_extension_core($phpbb_root_path),
+ ),
+ array(
+ new phpbb_di_pass_collection_pass(),
+ ),
+ $phpbb_root_path,
+ $phpEx
+);
+
+$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
+$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
// set up caching
$cache = $phpbb_container->get('cache');
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index 753e5eb226..09560946a6 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -75,10 +75,9 @@ else
// Include essential scripts
require($phpbb_root_path . 'includes/class_loader.' . $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);
+require($phpbb_root_path . 'includes/functions_container.' . $phpEx);
phpbb_require_updated('includes/functions_content.' . $phpEx, true);
@@ -86,17 +85,17 @@ 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_container = new ContainerBuilder();
-$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
-$loader->load('services.yml');
+// Setup class loader first
+$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx");
+$phpbb_class_loader->register();
+$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx");
+$phpbb_class_loader_ext->register();
-$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
-$phpbb_container->setParameter('core.php_ext', $phpEx);
+// Set up container
+$phpbb_container = phpbb_create_install_container($phpbb_root_path, $phpEx);
-$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');
+$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
+$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
// set up caching
$cache = $phpbb_container->get('cache');
diff --git a/tests/cron/task_provider_test.php b/tests/cron/task_provider_test.php
deleted file mode 100644
index ec853bb3ba..0000000000
--- a/tests/cron/task_provider_test.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $this->tasks = array(
- 'phpbb_cron_task_core_dummy_task',
- 'phpbb_cron_task_core_second_dummy_task',
- 'phpbb_ext_testext_cron_dummy_task',
- );
-
- $container = $this->getMock('Symfony\Component\DependencyInjection\TaggedContainerInterface');
- $container
- ->expects($this->once())
- ->method('findTaggedServiceIds')
- ->will($this->returnValue(array_flip($this->tasks)));
- $container
- ->expects($this->any())
- ->method('get')
- ->will($this->returnCallback(function ($name) {
- return new $name;
- }));
-
- $this->provider = new phpbb_cron_task_provider($container);
- }
-
- public function test_manager_finds_shipped_tasks()
- {
- $task_names = array();
- foreach ($this->provider as $task)
- {
- $task_names[] = $task->get_name();
- }
- sort($task_names);
-
- $this->assertEquals(array(
- 'phpbb_cron_task_core_dummy_task',
- 'phpbb_cron_task_core_second_dummy_task',
- 'phpbb_ext_testext_cron_dummy_task',
- ), $task_names);
- }
-}
diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php
new file mode 100644
index 0000000000..c2b8a0fc0b
--- /dev/null
+++ b/tests/di/create_container_test.php
@@ -0,0 +1,72 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_container.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/db/dbal.php';
+
+class phpbb_di_container_test extends phpbb_test_case
+{
+ public function test_phpbb_create_container()
+ {
+ $phpbb_root_path = __DIR__ . '/../../phpBB/';
+ $extensions = array(
+ new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
+ new phpbb_di_extension_core($phpbb_root_path),
+ );
+ $container = phpbb_create_container($extensions, $phpbb_root_path, 'php');
+
+ $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
+ }
+
+ public function test_phpbb_create_install_container()
+ {
+ $phpbb_root_path = __DIR__ . '/../../phpBB/';
+ $extensions = array(
+ new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
+ new phpbb_di_extension_core($phpbb_root_path),
+ );
+ $container = phpbb_create_install_container($phpbb_root_path, 'php');
+
+ $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
+ $this->assertTrue($container->isFrozen());
+ }
+
+ public function test_phpbb_create_compiled_container()
+ {
+ $phpbb_root_path = __DIR__ . '/../../phpBB/';
+ $extensions = array(
+ new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
+ new phpbb_di_extension_core($phpbb_root_path),
+ );
+ $container = phpbb_create_compiled_container($extensions, array(), $phpbb_root_path, 'php');
+
+ $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
+ $this->assertTrue($container->isFrozen());
+ }
+}
+
+class dbal_container_mock extends dbal
+{
+ public function sql_connect()
+ {
+ }
+
+ public function sql_query()
+ {
+ }
+
+ public function sql_fetchrow()
+ {
+ }
+
+ public function sql_freeresult()
+ {
+ }
+}
diff --git a/tests/di/fixtures/config.php b/tests/di/fixtures/config.php
new file mode 100644
index 0000000000..5033d2dc9f
--- /dev/null
+++ b/tests/di/fixtures/config.php
@@ -0,0 +1,11 @@
+<?php
+// phpBB 3.1.x auto-generated configuration file
+// Do not change anything in this file!
+$dbms = 'container_mock';
+$dbhost = '127.0.0.1';
+$dbport = '';
+$dbname = 'phpbb';
+$dbuser = 'root';
+$dbpasswd = '';
+$table_prefix = 'phpbb_';
+$acm_type = 'phpbb_cache_driver_null';
diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php
index f8fe060d99..9b9203e06a 100644
--- a/tests/event/dispatcher_test.php
+++ b/tests/event/dispatcher_test.php
@@ -11,7 +11,7 @@ class phpbb_event_dispatcher_test extends phpbb_test_case
{
public function test_trigger_event()
{
- $dispatcher = new phpbb_event_dispatcher();
+ $dispatcher = new phpbb_event_dispatcher(new phpbb_mock_container_builder());
$dispatcher->addListener('core.test_event', function (phpbb_event_data $event) {
$event['foo'] = $event['foo'] . '2';
diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php
new file mode 100644
index 0000000000..8a81dd72d1
--- /dev/null
+++ b/tests/mock/container_builder.php
@@ -0,0 +1,160 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\ScopeInterface;
+
+class phpbb_mock_container_builder implements ContainerInterface
+{
+ /**
+ * Sets a service.
+ *
+ * @param string $id The service identifier
+ * @param object $service The service instance
+ * @param string $scope The scope of the service
+ *
+ * @api
+ */
+ public function set($id, $service, $scope = self::SCOPE_CONTAINER)
+ {
+ }
+
+ /**
+ * Gets a service.
+ *
+ * @param string $id The service identifier
+ * @param int $invalidBehavior The behavior when the service does not exist
+ *
+ * @return object The associated service
+ *
+ * @throws InvalidArgumentException if the service is not defined
+ * @throws ServiceCircularReferenceException When a circular reference is detected
+ * @throws ServiceNotFoundException When the service is not defined
+ *
+ * @see Reference
+ *
+ * @api
+ */
+ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
+ {
+ }
+
+ /**
+ * Returns true if the given service is defined.
+ *
+ * @param string $id The service identifier
+ *
+ * @return Boolean true if the service is defined, false otherwise
+ *
+ * @api
+ */
+ public function has($id)
+ {
+ }
+
+ /**
+ * Gets a parameter.
+ *
+ * @param string $name The parameter name
+ *
+ * @return mixed The parameter value
+ *
+ * @throws InvalidArgumentException if the parameter is not defined
+ *
+ * @api
+ */
+ public function getParameter($name)
+ {
+ }
+
+ /**
+ * Checks if a parameter exists.
+ *
+ * @param string $name The parameter name
+ *
+ * @return Boolean The presence of parameter in container
+ *
+ * @api
+ */
+ public function hasParameter($name)
+ {
+ }
+
+ /**
+ * Sets a parameter.
+ *
+ * @param string $name The parameter name
+ * @param mixed $value The parameter value
+ *
+ * @api
+ */
+ public function setParameter($name, $value)
+ {
+ }
+
+ /**
+ * Enters the given scope
+ *
+ * @param string $name
+ *
+ * @api
+ */
+ public function enterScope($name)
+ {
+ }
+
+ /**
+ * Leaves the current scope, and re-enters the parent scope
+ *
+ * @param string $name
+ *
+ * @api
+ */
+ public function leaveScope($name)
+ {
+ }
+
+ /**
+ * Adds a scope to the container
+ *
+ * @param ScopeInterface $scope
+ *
+ * @api
+ */
+ public function addScope(ScopeInterface $scope)
+ {
+ }
+
+ /**
+ * Whether this container has the given scope
+ *
+ * @param string $name
+ *
+ * @return Boolean
+ *
+ * @api
+ */
+ public function hasScope($name)
+ {
+ }
+
+ /**
+ * Determines whether the given scope is currently active.
+ *
+ * It does however not check if the scope actually exists.
+ *
+ * @param string $name
+ *
+ * @return Boolean
+ *
+ * @api
+ */
+ public function isScopeActive($name)
+ {
+ }
+}