mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/11306] Introduce phpbb_create_default_container
Extracts default container construction to factory function, removing boilerplate duplication for container construction. PHPBB3-11306
This commit is contained in:
parent
53c4257bfa
commit
ea24de8de3
4 changed files with 19 additions and 36 deletions
|
@ -87,18 +87,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat
|
||||||
$phpbb_class_loader_ext->register();
|
$phpbb_class_loader_ext->register();
|
||||||
|
|
||||||
// Set up container
|
// Set up container
|
||||||
$phpbb_container = phpbb_create_dumped_container_unless_debug(
|
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
||||||
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(),
|
|
||||||
new phpbb_di_pass_kernel_pass(),
|
|
||||||
),
|
|
||||||
$phpbb_root_path,
|
|
||||||
$phpEx
|
|
||||||
);
|
|
||||||
|
|
||||||
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
|
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
|
||||||
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
|
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
|
||||||
|
|
|
@ -56,18 +56,7 @@ if (isset($_GET['avatar']))
|
||||||
$phpbb_class_loader_ext->register();
|
$phpbb_class_loader_ext->register();
|
||||||
|
|
||||||
// Set up container
|
// Set up container
|
||||||
$phpbb_container = phpbb_create_dumped_container_unless_debug(
|
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
||||||
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(),
|
|
||||||
new phpbb_di_pass_kernel_pass(),
|
|
||||||
),
|
|
||||||
$phpbb_root_path,
|
|
||||||
$phpEx
|
|
||||||
);
|
|
||||||
|
|
||||||
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
|
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
|
||||||
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
|
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
|
||||||
|
|
|
@ -135,6 +135,22 @@ function phpbb_create_dumped_container_unless_debug(array $extensions, array $pa
|
||||||
return $container_factory($extensions, $passes, $phpbb_root_path, $php_ext);
|
return $container_factory($extensions, $passes, $phpbb_root_path, $php_ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function phpbb_create_default_container($phpbb_root_path, $php_ext)
|
||||||
|
{
|
||||||
|
return phpbb_create_dumped_container_unless_debug(
|
||||||
|
array(
|
||||||
|
new phpbb_di_extension_config($phpbb_root_path . 'config.' . $php_ext),
|
||||||
|
new phpbb_di_extension_core($phpbb_root_path),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
new phpbb_di_pass_collection_pass(),
|
||||||
|
new phpbb_di_pass_kernel_pass(),
|
||||||
|
),
|
||||||
|
$phpbb_root_path,
|
||||||
|
$php_ext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function phpbb_container_filename($phpbb_root_path, $php_ext)
|
function phpbb_container_filename($phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
$filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path);
|
$filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path);
|
||||||
|
|
|
@ -109,18 +109,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat
|
||||||
$phpbb_class_loader_ext->register();
|
$phpbb_class_loader_ext->register();
|
||||||
|
|
||||||
// Set up container
|
// Set up container
|
||||||
$phpbb_container = phpbb_create_dumped_container_unless_debug(
|
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
||||||
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(),
|
|
||||||
new phpbb_di_pass_kernel_pass(),
|
|
||||||
),
|
|
||||||
$phpbb_root_path,
|
|
||||||
$phpEx
|
|
||||||
);
|
|
||||||
|
|
||||||
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
|
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
|
||||||
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
|
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
|
||||||
|
|
Loading…
Add table
Reference in a new issue