diff options
author | Tristan Darricau <github@nicofuma.fr> | 2014-06-27 19:10:18 +0200 |
---|---|---|
committer | Tristan Darricau <github@nicofuma.fr> | 2014-07-07 01:02:06 +0200 |
commit | 86205454afb0b851534f7309c668dc092863c8ce (patch) | |
tree | 7d12135e6b53551fc9701702b581f0250d358b8b /phpBB/phpbb/di | |
parent | cdf87e0078e3c4d78bfd1b9d12100eb1451b5633 (diff) | |
download | forums-86205454afb0b851534f7309c668dc092863c8ce.tar forums-86205454afb0b851534f7309c668dc092863c8ce.tar.gz forums-86205454afb0b851534f7309c668dc092863c8ce.tar.bz2 forums-86205454afb0b851534f7309c668dc092863c8ce.tar.xz forums-86205454afb0b851534f7309c668dc092863c8ce.zip |
[ticket/12775] Add customs parameters
PHPBB3-12775
Diffstat (limited to 'phpBB/phpbb/di')
-rw-r--r-- | phpBB/phpbb/di/container_factory.php | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/phpBB/phpbb/di/container_factory.php b/phpBB/phpbb/di/container_factory.php index aeea025b94..a9bc0ea7f7 100644 --- a/phpBB/phpbb/di/container_factory.php +++ b/phpBB/phpbb/di/container_factory.php @@ -94,6 +94,19 @@ class container_factory protected $dump_container = true; /** + * Custom parameters to inject into the container. + * + * Default to true: + * array( + * 'core.root_path', $this->phpbb_root_path, + * 'core.php_ext', $this->php_ext, + * ); + * + * @var array + */ + protected $custom_parameters = null; + + /** * Constructor * * @param string $phpbb_root_path Path to the phpbb includes directory. @@ -146,8 +159,7 @@ class container_factory $this->container->addCompilerPass(new \phpbb\di\pass\kernel_pass()); } - $this->container->setParameter('core.root_path', $this->phpbb_root_path); - $this->container->setParameter('core.php_ext', $this->php_ext); + $this->inject_custom_parameters(); $this->container->compile(); @@ -234,7 +246,7 @@ class container_factory * * @var bool $dump_container */ - public function setDumpContainer($dump_container) + public function set_dump_container($dump_container) { $this->dump_container = $dump_container; } @@ -244,12 +256,22 @@ class container_factory * * @param string $config_path */ - public function setConfigPath($config_path) + public function set_config_path($config_path) { $this->config_path = $config_path; } /** + * Set custom parameters to inject into the container. + * + * @param array $custom_parameters + */ + public function set_custom_parameters($custom_parameters) + { + $this->custom_parameters = $custom_parameters; + } + + /** * Dump the container to the disk. * * @param string $container_filename The name of the file. @@ -349,6 +371,25 @@ class container_factory } /** + * Inject the customs parameters into the container + */ + protected function inject_custom_parameters() + { + if ($this->custom_parameters === null) + { + $this->custom_parameters = array( + 'core.root_path', $this->phpbb_root_path, + 'core.php_ext', $this->php_ext, + ); + } + + foreach ($this->custom_parameters as $key => $value) + { + $this->container->setParameter($key, $value); + } + } + + /** * Get the filename under which the dumped container will be stored. * * @return string Path for dumped container |