aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/di
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/di')
-rw-r--r--phpBB/phpbb/di/container_builder.php9
-rw-r--r--phpBB/phpbb/di/extension/container_configuration.php11
-rw-r--r--phpBB/phpbb/di/extension/core.php8
-rw-r--r--phpBB/phpbb/di/extension/tables.php59
-rw-r--r--phpBB/phpbb/di/service_collection.php31
5 files changed, 116 insertions, 2 deletions
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index 8c1ce8bde2..70ceb9b5e3 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -158,13 +158,18 @@ class container_builder
}
else
{
- $this->container_extensions = array(new extension\core($this->get_config_path()));
+ $this->container_extensions = [
+ new extension\core($this->get_config_path()),
+ ];
if ($this->use_extensions)
{
$this->load_extensions();
}
+ // Add tables extension after all extensions
+ $this->container_extensions[] = new extension\tables();
+
// Inject the config
if ($this->config_php_file)
{
@@ -481,7 +486,7 @@ class container_builder
$cached_container_dump = $dumper->dump(array(
'class' => 'phpbb_cache_container',
- 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
+ 'base_class' => 'Symfony\\Component\\DependencyInjection\\Container',
));
$cache->write($cached_container_dump, $this->container->getResources());
diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php
index 4585d6509e..57e7ef6ca6 100644
--- a/phpBB/phpbb/di/extension/container_configuration.php
+++ b/phpBB/phpbb/di/extension/container_configuration.php
@@ -31,10 +31,15 @@ class container_configuration implements ConfigurationInterface
$rootNode
->children()
->booleanNode('require_dev_dependencies')->defaultValue(false)->end()
+ ->booleanNode('allow_install_dir')->defaultValue(false)->end()
->arrayNode('debug')
->addDefaultsIfNotSet()
->children()
->booleanNode('exceptions')->defaultValue(false)->end()
+ ->booleanNode('load_time')->defaultValue(false)->end()
+ ->booleanNode('sql_explain')->defaultValue(false)->end()
+ ->booleanNode('memory')->defaultValue(false)->end()
+ ->booleanNode('show_errors')->defaultValue(false)->end()
->end()
->end()
->arrayNode('twig')
@@ -45,6 +50,12 @@ class container_configuration implements ConfigurationInterface
->booleanNode('enable_debug_extension')->defaultValue(false)->end()
->end()
->end()
+ ->arrayNode('session')
+ ->addDefaultsIfNotSet()
+ ->children()
+ ->booleanNode('log_errors')->defaultValue(false)->end()
+ ->end()
+ ->end()
->end()
;
return $treeBuilder;
diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php
index 67150f0103..0497c90e2a 100644
--- a/phpBB/phpbb/di/extension/core.php
+++ b/phpBB/phpbb/di/extension/core.php
@@ -71,6 +71,8 @@ class core extends Extension
}
}
+ $container->setParameter('allow_install_dir', $config['allow_install_dir']);
+
// Set the Twig options if defined in the environment
$definition = $container->getDefinition('template.twig.environment');
$twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION);
@@ -97,6 +99,12 @@ class core extends Extension
{
$container->setParameter('debug.' . $name, $value);
}
+
+ // Set the log options
+ foreach ($config['session'] as $name => $value)
+ {
+ $container->setParameter('session.' . $name, $value);
+ }
}
/**
diff --git a/phpBB/phpbb/di/extension/tables.php b/phpBB/phpbb/di/extension/tables.php
new file mode 100644
index 0000000000..40684b6038
--- /dev/null
+++ b/phpBB/phpbb/di/extension/tables.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\di\extension;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+
+/**
+ * Container tables extension
+ */
+class tables extends Extension
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function load(array $configs, ContainerBuilder $container)
+ {
+ // Tables is a reserved parameter and will be overwritten at all times
+ $tables = [];
+
+ // Add access via 'tables' parameter to acquire array with all tables
+ $parameterBag = $container->getParameterBag();
+ $parameters = $parameterBag->all();
+ foreach ($parameters as $parameter_name => $parameter_value)
+ {
+ if (!preg_match('/tables\.(.+)/', $parameter_name, $matches))
+ {
+ continue;
+ }
+
+ $tables[$matches[1]] = $parameter_value;
+ }
+
+ $container->setParameter('tables', $tables);
+ }
+
+ /**
+ * Returns the recommended alias to use in XML.
+ *
+ * This alias is also the mandatory prefix to use when using YAML.
+ *
+ * @return string The alias
+ */
+ public function getAlias()
+ {
+ return 'tables';
+ }
+}
diff --git a/phpBB/phpbb/di/service_collection.php b/phpBB/phpbb/di/service_collection.php
index 8e9175e204..8c1c172e36 100644
--- a/phpBB/phpbb/di/service_collection.php
+++ b/phpBB/phpbb/di/service_collection.php
@@ -103,4 +103,35 @@ class service_collection extends \ArrayObject
{
return $this->service_classes;
}
+
+ /**
+ * Returns the service associated to a class
+ *
+ * @return mixed
+ * @throw \RuntimeException if the
+ */
+ public function get_by_class($class)
+ {
+ $service_id = null;
+
+ foreach ($this->service_classes as $id => $service_class)
+ {
+ if ($service_class === $class)
+ {
+ if ($service_id !== null)
+ {
+ throw new \RuntimeException('More than one service definitions found for class "'.$class.'" in collection.');
+ }
+
+ $service_id = $id;
+ }
+ }
+
+ if ($service_id === null)
+ {
+ throw new \RuntimeException('No service found for class "'.$class.'" in collection.');
+ }
+
+ return $this->offsetGet($service_id);
+ }
}