mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/11574] Use alternate DI config file for updater
PHPBB3-11574
This commit is contained in:
parent
6c52fae750
commit
1dea0286a4
4 changed files with 19 additions and 22 deletions
|
@ -26,19 +26,19 @@ use Symfony\Component\Config\FileLocator;
|
|||
class phpbb_di_extension_core extends Extension
|
||||
{
|
||||
/**
|
||||
* phpBB Root path
|
||||
* Config path
|
||||
* @var string
|
||||
*/
|
||||
protected $root_path;
|
||||
protected $config_path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $root_path Root path
|
||||
* @param string $config_path Config path
|
||||
*/
|
||||
public function __construct($root_path)
|
||||
public function __construct($config_path)
|
||||
{
|
||||
$this->root_path = $root_path;
|
||||
$this->config_path = $config_path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,18 +51,9 @@ class phpbb_di_extension_core extends Extension
|
|||
*/
|
||||
public function load(array $config, ContainerBuilder $container)
|
||||
{
|
||||
// If we are in install, try to use the updated version, when available
|
||||
if (defined('IN_INSTALL') && file_exists($this->root_path . 'install/update/new/config/services.yml'))
|
||||
{
|
||||
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'install/update/new/config')));
|
||||
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path)));
|
||||
$loader->load('services.yml');
|
||||
}
|
||||
else if (file_exists($this->root_path . 'config/services.yml'))
|
||||
{
|
||||
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'config')));
|
||||
$loader->load('services.yml');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the recommended alias to use in XML.
|
||||
|
|
|
@ -53,7 +53,10 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext)
|
|||
*/
|
||||
function phpbb_create_install_container($phpbb_root_path, $php_ext)
|
||||
{
|
||||
$core = new phpbb_di_extension_core($phpbb_root_path);
|
||||
$other_config_path = $phpbb_root_path . 'install/update/new/config';
|
||||
$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config';
|
||||
|
||||
$core = new phpbb_di_extension_core($config_path);
|
||||
$container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext);
|
||||
|
||||
$container->setParameter('core.root_path', $phpbb_root_path);
|
||||
|
@ -175,7 +178,7 @@ 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),
|
||||
new phpbb_di_extension_core($phpbb_root_path . 'config'),
|
||||
),
|
||||
array(
|
||||
new phpbb_di_pass_collection_pass(),
|
||||
|
|
|
@ -121,9 +121,12 @@ $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includ
|
|||
$phpbb_class_loader->register();
|
||||
|
||||
// Set up container (must be done here because extensions table may not exist)
|
||||
$other_config_path = $phpbb_root_path . 'install/update/new/config';
|
||||
$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path;
|
||||
|
||||
$container_extensions = array(
|
||||
new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx),
|
||||
new phpbb_di_extension_core($phpbb_root_path),
|
||||
new phpbb_di_extension_core($config_path),
|
||||
);
|
||||
$container_passes = array(
|
||||
new phpbb_di_pass_collection_pass(),
|
||||
|
|
|
@ -17,7 +17,7 @@ class phpbb_di_container_test extends phpbb_test_case
|
|||
$phpbb_root_path = __DIR__ . '/../../phpBB/';
|
||||
$extensions = array(
|
||||
new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
|
||||
new phpbb_di_extension_core($phpbb_root_path),
|
||||
new phpbb_di_extension_core($phpbb_root_path . 'config'),
|
||||
);
|
||||
$container = phpbb_create_container($extensions, $phpbb_root_path, 'php');
|
||||
|
||||
|
@ -29,7 +29,7 @@ class phpbb_di_container_test extends phpbb_test_case
|
|||
$phpbb_root_path = __DIR__ . '/../../phpBB/';
|
||||
$extensions = array(
|
||||
new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
|
||||
new phpbb_di_extension_core($phpbb_root_path),
|
||||
new phpbb_di_extension_core($phpbb_root_path . 'config'),
|
||||
);
|
||||
$container = phpbb_create_install_container($phpbb_root_path, 'php');
|
||||
|
||||
|
@ -42,7 +42,7 @@ class phpbb_di_container_test extends phpbb_test_case
|
|||
$phpbb_root_path = __DIR__ . '/../../phpBB/';
|
||||
$extensions = array(
|
||||
new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
|
||||
new phpbb_di_extension_core($phpbb_root_path),
|
||||
new phpbb_di_extension_core($phpbb_root_path . 'config'),
|
||||
);
|
||||
$container = phpbb_create_compiled_container($extensions, array(), $phpbb_root_path, 'php');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue