diff options
-rw-r--r-- | core/Application/Environment.php | 35 | ||||
-rw-r--r-- | misc/cron/updatetoken.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/archive.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/console | 2 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/index.php | 2 | ||||
-rwxr-xr-x | tests/PHPUnit/proxy/piwik.php | 2 |
6 files changed, 21 insertions, 24 deletions
diff --git a/core/Application/Environment.php b/core/Application/Environment.php index 967b4d377b..b70acf461d 100644 --- a/core/Application/Environment.php +++ b/core/Application/Environment.php @@ -41,9 +41,9 @@ class Environment { /** * @internal - * @var EnvironmentManipulator[] + * @var EnvironmentManipulator */ - private static $globalEnvironmentManipulators = array(); + private static $globalEnvironmentManipulator = null; /** * @var string @@ -175,43 +175,40 @@ class Environment * @param EnvironmentManipulator $manipulator * @internal */ - public static function addEnvironmentManipulator(EnvironmentManipulator $manipulator) + public static function setGlobalEnvironmentManipulator(EnvironmentManipulator $manipulator) { - self::$globalEnvironmentManipulators[] = $manipulator; + self::$globalEnvironmentManipulator = $manipulator; } private function getGlobalSettingsProviderOverride() { - foreach (self::$globalEnvironmentManipulators as $manipulator) { - $result = $manipulator->makeGlobalSettingsProvider(); - if (!empty($result)) { - return $result; - } + if (self::$globalEnvironmentManipulator) { + return self::$globalEnvironmentManipulator->makeGlobalSettingsProvider(); + } else { + return null; } - - return null; } private function invokeBeforeContainerCreatedHook() { - foreach (self::$globalEnvironmentManipulators as $manipulator) { - $manipulator->beforeContainerCreated(); + if (self::$globalEnvironmentManipulator) { + return self::$globalEnvironmentManipulator->beforeContainerCreated(); } } private function getExtraDefinitionsFromManipulators() { - $result = array(); - foreach (self::$globalEnvironmentManipulators as $manipulator) { - $result = array_merge($result, $manipulator->getExtraDefinitions()); + if (self::$globalEnvironmentManipulator) { + return self::$globalEnvironmentManipulator->getExtraDefinitions(); + } else { + return array(); } - return $result; } private function invokeEnvironmentBootstrappedHook() { - foreach (self::$globalEnvironmentManipulators as $manipulator) { - $manipulator->onEnvironmentBootstrapped(); + if (self::$globalEnvironmentManipulator) { + self::$globalEnvironmentManipulator->onEnvironmentBootstrapped(); } } } diff --git a/misc/cron/updatetoken.php b/misc/cron/updatetoken.php index 21f28b8cdd..c06684e4a3 100644 --- a/misc/cron/updatetoken.php +++ b/misc/cron/updatetoken.php @@ -37,7 +37,7 @@ $testmode = in_array('--testmode', $_SERVER['argv']); if ($testmode) { define('PIWIK_TEST_MODE', true); - Environment::addEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); + Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); } function getPiwikDomain() diff --git a/tests/PHPUnit/proxy/archive.php b/tests/PHPUnit/proxy/archive.php index ba4faeca84..a7f4222efe 100644 --- a/tests/PHPUnit/proxy/archive.php +++ b/tests/PHPUnit/proxy/archive.php @@ -7,7 +7,7 @@ define('PIWIK_ARCHIVE_NO_TRUNCATE', true); require realpath(dirname(__FILE__)) . "/includes.php"; -Environment::addEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); +Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); // include archive.php, and let 'er rip require_once PIWIK_INCLUDE_PATH . "/misc/cron/archive.php"; diff --git a/tests/PHPUnit/proxy/console b/tests/PHPUnit/proxy/console index f58f09d1fd..31c2b9c2b5 100644 --- a/tests/PHPUnit/proxy/console +++ b/tests/PHPUnit/proxy/console @@ -6,6 +6,6 @@ use Piwik\Tests\Framework\TestingEnvironmentVariables; require realpath(dirname(__FILE__)) . "/includes.php"; -Environment::addEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); +Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); require_once PIWIK_INCLUDE_PATH . "/console"; diff --git a/tests/PHPUnit/proxy/index.php b/tests/PHPUnit/proxy/index.php index 4eb3497882..fe75475688 100644 --- a/tests/PHPUnit/proxy/index.php +++ b/tests/PHPUnit/proxy/index.php @@ -10,6 +10,6 @@ use Piwik\Tests\Framework\TestingEnvironmentVariables; require realpath(dirname(__FILE__)) . "/includes.php"; -Environment::addEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); +Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); include PIWIK_INCLUDE_PATH . '/index.php';
\ No newline at end of file diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php index f1e94930c3..5e542379f6 100755 --- a/tests/PHPUnit/proxy/piwik.php +++ b/tests/PHPUnit/proxy/piwik.php @@ -32,7 +32,7 @@ try { }) ); - Environment::addEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables(), $globalObservers)); + Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables(), $globalObservers)); GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; |