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:
authorMatthieu Napoli <matthieu@mnapoli.fr>2015-03-13 03:36:51 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-03-16 00:35:51 +0300
commitfa55ac8a79cccdab6704e20b513fb0bc6d898b00 (patch)
tree4d4b47c2584a6d7dc7820d602f4247878c90ef65 /core
parentca2f0d3047cee0e084bf02d1e6bae4761eb7c3c0 (diff)
Tests fixtures can provide DI configuration
Diffstat (limited to 'core')
-rw-r--r--core/Container/ContainerFactory.php12
-rw-r--r--core/Container/StaticContainer.php14
2 files changed, 24 insertions, 2 deletions
diff --git a/core/Container/ContainerFactory.php b/core/Container/ContainerFactory.php
index cbbc36a00a..af2a09b695 100644
--- a/core/Container/ContainerFactory.php
+++ b/core/Container/ContainerFactory.php
@@ -28,11 +28,17 @@ class ContainerFactory
private $environment;
/**
+ * @var array
+ */
+ private $definitions;
+
+ /**
* @param string|null $environment Optional environment config to load.
*/
- public function __construct($environment = null)
+ public function __construct($environment = null, array $definitions = array())
{
$this->environment = $environment;
+ $this->definitions = $definitions;
}
/**
@@ -69,6 +75,10 @@ class ContainerFactory
// Environment config
$this->addEnvironmentConfig($builder);
+ if (!empty($this->definitions)) {
+ $builder->addDefinitions($this->definitions);
+ }
+
return $builder->build();
}
diff --git a/core/Container/StaticContainer.php b/core/Container/StaticContainer.php
index 874851acde..8468dce2ae 100644
--- a/core/Container/StaticContainer.php
+++ b/core/Container/StaticContainer.php
@@ -32,6 +32,13 @@ class StaticContainer
private static $environment;
/**
+ * Definitions to register in the container.
+ *
+ * @var array
+ */
+ private static $definitions = array();
+
+ /**
* @return Container
*/
public static function getContainer()
@@ -63,7 +70,7 @@ class StaticContainer
*/
private static function createContainer()
{
- $containerFactory = new ContainerFactory(self::$environment);
+ $containerFactory = new ContainerFactory(self::$environment, self::$definitions);
return $containerFactory->create();
}
@@ -77,6 +84,11 @@ class StaticContainer
self::$environment = $environment;
}
+ public static function addDefinitions(array $definitions)
+ {
+ self::$definitions = $definitions;
+ }
+
/**
* Proxy to Container::get()
*