Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Application/Environment.php14
-rw-r--r--core/Application/EnvironmentManipulator.php7
-rw-r--r--core/Container/ContainerFactory.php32
3 files changed, 34 insertions, 19 deletions
diff --git a/core/Application/Environment.php b/core/Application/Environment.php
index b70acf461d..61df20a32f 100644
--- a/core/Application/Environment.php
+++ b/core/Application/Environment.php
@@ -120,7 +120,10 @@ class Environment
$extraDefinitions = $this->getExtraDefinitionsFromManipulators();
$definitions = array_merge(StaticContainer::getDefinitions(), $extraDefinitions, array($this->definitions));
- $containerFactory = new ContainerFactory($pluginList, $settings, $this->environment, $definitions);
+ $environments = array($this->environment);
+ $environments = array_merge($environments, $this->getExtraEnvironmentsFromManipulators());
+
+ $containerFactory = new ContainerFactory($pluginList, $settings, $environments, $definitions);
return $containerFactory->create();
}
@@ -211,4 +214,13 @@ class Environment
self::$globalEnvironmentManipulator->onEnvironmentBootstrapped();
}
}
+
+ private function getExtraEnvironmentsFromManipulators()
+ {
+ if (self::$globalEnvironmentManipulator) {
+ return self::$globalEnvironmentManipulator->getExtraEnvironments();
+ } else {
+ return array();
+ }
+ }
}
diff --git a/core/Application/EnvironmentManipulator.php b/core/Application/EnvironmentManipulator.php
index d70b22f3d6..1740de6c44 100644
--- a/core/Application/EnvironmentManipulator.php
+++ b/core/Application/EnvironmentManipulator.php
@@ -40,4 +40,11 @@ interface EnvironmentManipulator
* Invoked after the container is created and the environment is considered bootstrapped.
*/
public function onEnvironmentBootstrapped();
+
+ /**
+ * Return an array of environment names to apply after the normal environment.
+ *
+ * @return string[]
+ */
+ public function getExtraEnvironments();
}
diff --git a/core/Container/ContainerFactory.php b/core/Container/ContainerFactory.php
index 9586fe098e..7538c57afe 100644
--- a/core/Container/ContainerFactory.php
+++ b/core/Container/ContainerFactory.php
@@ -14,6 +14,7 @@ use Doctrine\Common\Cache\ArrayCache;
use Piwik\Application\Kernel\GlobalSettingsProvider;
use Piwik\Application\Kernel\PluginList;
use Piwik\Plugin\Manager;
+use Piwik\SettingsServer;
use Piwik\Tests\Framework\TestingEnvironmentVariables;
use Piwik\Tests\Framework\TestingEnvironmentVariablesDefinitionSource;
@@ -33,11 +34,11 @@ class ContainerFactory
private $settings;
/**
- * Optional environment config to load.
+ * Optional environment configs to load.
*
- * @var string|null
+ * @var string[]
*/
- private $environment;
+ private $environments;
/**
* @var array[]
@@ -47,14 +48,14 @@ class ContainerFactory
/**
* @param PluginList $pluginList
* @param GlobalSettingsProvider $settings
- * @param string|null $environment Optional environment config to load.
+ * @param string[] $environment Optional environment configs to load.
* @param array[] $definitions
*/
- public function __construct(PluginList $pluginList, GlobalSettingsProvider $settings, $environment = null, array $definitions = array())
+ public function __construct(PluginList $pluginList, GlobalSettingsProvider $settings, array $environments = array(), array $definitions = array())
{
$this->pluginList = $pluginList;
$this->settings = $settings;
- $this->environment = $environment;
+ $this->environments = $environments;
$this->definitions = $definitions;
}
@@ -90,14 +91,14 @@ class ContainerFactory
}
// Environment config
- $this->addEnvironmentConfig($builder, $this->environment);
+ foreach ($this->environments as $environment) {
+ $this->addEnvironmentConfig($builder, $environment);
+ }
// Test config
if (defined('PIWIK_TEST_MODE')) {
$vars = new TestingEnvironmentVariables();
$builder->addDefinitions(new TestingEnvironmentVariablesDefinitionSource($vars));
-
- $this->addEnvironmentConfig($builder, 'test');
}
if (!empty($this->definitions)) {
@@ -138,15 +139,10 @@ class ContainerFactory
$builder->addDefinitions($file);
}
- $environmentFile = $baseDir . '/config/' . $this->environment . '.php';
- if (file_exists($environmentFile)) {
- $builder->addDefinitions($environmentFile);
- }
-
- if (defined('PIWIK_TEST_MODE')) {
- $testEnvironmentFile = $baseDir . '/config/test.php';
- if (file_exists($testEnvironmentFile)) {
- $builder->addDefinitions($testEnvironmentFile);
+ foreach ($this->environments as $environment) {
+ $environmentFile = $baseDir . '/config/' . $environment . '.php';
+ if (file_exists($environmentFile)) {
+ $builder->addDefinitions($environmentFile);
}
}
}