diff options
author | diosmosis <benaka@piwik.pro> | 2015-06-06 00:31:42 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-06-06 00:35:46 +0300 |
commit | 28329746406b75bc1b54ee598a915b85b03655ad (patch) | |
tree | 45c22c606d63eea1b1393d7482a55773a70b3622 /core/Application | |
parent | aff138ab0347002774f3beafb2b77fe2880d9526 (diff) |
Allow multiple environments to be specified to Environment constructor. Add hook in EnvironmentManipulator to get extra environment names, and specify test environment this way instead of through detecting PIWIK_TEST_MODE.
Diffstat (limited to 'core/Application')
-rw-r--r-- | core/Application/Environment.php | 14 | ||||
-rw-r--r-- | core/Application/EnvironmentManipulator.php | 7 |
2 files changed, 20 insertions, 1 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(); } |