mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/12620] Add the support of the environments for the ext services
We look for an environment.yml file in the config/PHPBB_ENVIRONMENT/ directory of the extensionss. If the directory does not exist we look for the environment.yml file in the 'default' environment and finally for the services.yml file in the config/ directory. PHPBB3-12620
This commit is contained in:
parent
0306fefe04
commit
0bf3d2d962
6 changed files with 33 additions and 3 deletions
|
@ -45,10 +45,32 @@ class ext extends Extension
|
||||||
{
|
{
|
||||||
foreach ($this->paths as $path)
|
foreach ($this->paths as $path)
|
||||||
{
|
{
|
||||||
if (file_exists($path . '/config/services.yml'))
|
$services_directory = false;
|
||||||
|
$services_file = false;
|
||||||
|
|
||||||
|
if (file_exists($path . 'config/' . PHPBB_ENVIRONMENT . '/environment.yml'))
|
||||||
{
|
{
|
||||||
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($path . '/config')));
|
$services_directory = $path . 'config/' . PHPBB_ENVIRONMENT;
|
||||||
$loader->load('services.yml');
|
$services_file = 'environment.yml';
|
||||||
|
}
|
||||||
|
else if (!is_dir($path . 'config/' . PHPBB_ENVIRONMENT))
|
||||||
|
{
|
||||||
|
if (file_exists($path . 'config/default/environment.yml'))
|
||||||
|
{
|
||||||
|
$services_directory = $path . 'config/default';
|
||||||
|
$services_file = 'environment.yml';
|
||||||
|
}
|
||||||
|
else if (!is_dir($path . 'config/default') && file_exists($path . '/config/services.yml'))
|
||||||
|
{
|
||||||
|
$services_directory = $path . 'config';
|
||||||
|
$services_file = 'services.yml';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($services_directory && $services_file)
|
||||||
|
{
|
||||||
|
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($services_directory)));
|
||||||
|
$loader->load($services_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ namespace
|
||||||
|
|
||||||
// Checks use_extensions
|
// Checks use_extensions
|
||||||
$this->assertTrue($container->hasParameter('enabled'));
|
$this->assertTrue($container->hasParameter('enabled'));
|
||||||
|
$this->assertTrue($container->hasParameter('enabled_2'));
|
||||||
|
$this->assertTrue($container->hasParameter('enabled_3'));
|
||||||
$this->assertFalse($container->hasParameter('disabled'));
|
$this->assertFalse($container->hasParameter('disabled'));
|
||||||
$this->assertFalse($container->hasParameter('available'));
|
$this->assertFalse($container->hasParameter('available'));
|
||||||
|
|
||||||
|
@ -201,6 +203,8 @@ namespace phpbb\db\driver
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('ext_name' => 'vendor/enabled'),
|
array('ext_name' => 'vendor/enabled'),
|
||||||
|
array('ext_name' => 'vendor/enabled-2'),
|
||||||
|
array('ext_name' => 'vendor/enabled-3'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml
vendored
Normal file
2
tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
parameters:
|
||||||
|
enabled_2: true
|
2
tests/di/fixtures/ext/vendor/enabled-3/config/services.yml
vendored
Normal file
2
tests/di/fixtures/ext/vendor/enabled-3/config/services.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
parameters:
|
||||||
|
enabled_3: true
|
Loading…
Add table
Reference in a new issue