1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[feature/compiled-dic] Compile the DI Container into a cached class

PHPBB3-11152
This commit is contained in:
David King
2012-10-19 19:53:29 -04:00
committed by Igor Wiedler
parent 957508c8b1
commit f48709f5bb
20 changed files with 692 additions and 273 deletions

View File

@@ -109,20 +109,28 @@ 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_compiled_container(
array(
new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx),
new phpbb_di_extension_core($phpbb_root_path),
),
array(
new phpbb_event_kernel_compiler_pass(),
),
$phpbb_root_path . 'config.' . $phpEx,
$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');