aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/di/container_builder.php
diff options
context:
space:
mode:
authorNicofuma <github@nicofuma.fr>2015-05-10 23:54:49 +0200
committerNicofuma <github@nicofuma.fr>2015-05-14 23:04:23 +0200
commit02af9385a13543f3f6bd9cb1500fd8508bcd35ac (patch)
treef975127f8aabaf1777589240a248ffefee1429f7 /phpBB/phpbb/di/container_builder.php
parent549fe66d90eed1d6a4fee6f5f706c73455d73596 (diff)
downloadforums-02af9385a13543f3f6bd9cb1500fd8508bcd35ac.tar
forums-02af9385a13543f3f6bd9cb1500fd8508bcd35ac.tar.gz
forums-02af9385a13543f3f6bd9cb1500fd8508bcd35ac.tar.bz2
forums-02af9385a13543f3f6bd9cb1500fd8508bcd35ac.tar.xz
forums-02af9385a13543f3f6bd9cb1500fd8508bcd35ac.zip
[ticket/13770] Fix tests
PHPBB3-13770
Diffstat (limited to 'phpBB/phpbb/di/container_builder.php')
-rw-r--r--phpBB/phpbb/di/container_builder.php83
1 files changed, 48 insertions, 35 deletions
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index 3886bfdd5d..9f2e860932 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -21,6 +21,7 @@ use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
+use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
class container_builder
@@ -130,50 +131,55 @@ class container_builder
{
require($config_cache->getPath());
$this->container = new \phpbb_cache_container();
-
- return $this->container;
}
-
- $this->container_extensions = array(new extension\core($this->get_config_path()));
-
- if ($this->use_extensions)
+ else
{
- $this->load_extensions();
- }
+ $this->container_extensions = array(new extension\core($this->get_config_path()));
- // Inject the config
- if ($this->config_php_file)
- {
- $this->container_extensions[] = new extension\config($this->config_php_file);
- }
+ if ($this->use_extensions)
+ {
+ $this->load_extensions();
+ }
- $this->container = $this->create_container($this->container_extensions);
+ // Inject the config
+ if ($this->config_php_file)
+ {
+ $this->container_extensions[] = new extension\config($this->config_php_file);
+ }
- // Easy collections through tags
- $this->container->addCompilerPass(new pass\collection_pass());
+ $this->container = $this->create_container($this->container_extensions);
- // Event listeners "phpBB style"
- $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener'));
+ // Easy collections through tags
+ $this->container->addCompilerPass(new pass\collection_pass());
- // Event listeners "Symfony style"
- $this->container->addCompilerPass(new RegisterListenersPass('dispatcher'));
+ // Event listeners "phpBB style"
+ $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener'));
- $filesystem = new filesystem();
- $loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path())));
- $loader->load($this->container->getParameter('core.environment') . '/config.yml');
+ // Event listeners "Symfony style"
+ $this->container->addCompilerPass(new RegisterListenersPass('dispatcher'));
- $this->inject_custom_parameters();
+ $filesystem = new filesystem();
+ $loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path())));
+ $loader->load($this->container->getParameter('core.environment') . '/config.yml');
- if ($this->compile_container)
- {
- $this->container->compile();
+ $this->inject_custom_parameters();
- if ($this->use_cache)
+ if ($this->compile_container)
{
- $this->dump_container($config_cache);
+ $this->container->compile();
+
+ if ($this->use_cache)
+ {
+ $this->dump_container($config_cache);
+ }
}
}
+ if ($this->compile_container && $this->config_php_file)
+ {
+ $this->container->set('config.php', $this->config_php_file);
+ }
+
return $this->container;
}
@@ -394,13 +400,20 @@ class container_builder
*/
protected function dump_container($cache)
{
- $dumper = new PhpDumper($this->container);
- $cached_container_dump = $dumper->dump(array(
- 'class' => 'phpbb_cache_container',
- 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
- ));
+ try
+ {
+ $dumper = new PhpDumper($this->container);
+ $cached_container_dump = $dumper->dump(array(
+ 'class' => 'phpbb_cache_container',
+ 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
+ ));
- $cache->write($cached_container_dump, $this->container->getResources());
+ $cache->write($cached_container_dump, $this->container->getResources());
+ }
+ catch (IOException $e)
+ {
+ // Don't fail if the cache isn't writeable
+ }
}
/**