mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/12632] Add twig.debug and twig.auto_reload in config.yml
PHPBB3-13206 PHPBB3-12632
This commit is contained in:
parent
6be8841a57
commit
f821130c3a
7 changed files with 42 additions and 1 deletions
|
@ -11,6 +11,7 @@ services:
|
||||||
- %core.template.cache_path%
|
- %core.template.cache_path%
|
||||||
- @ext.manager
|
- @ext.manager
|
||||||
- @template.twig.loader
|
- @template.twig.loader
|
||||||
|
- []
|
||||||
|
|
||||||
template.twig.lexer:
|
template.twig.lexer:
|
||||||
class: phpbb\template\twig\lexer
|
class: phpbb\template\twig\lexer
|
||||||
|
|
|
@ -5,4 +5,6 @@ core:
|
||||||
require_dev_dependencies: true
|
require_dev_dependencies: true
|
||||||
|
|
||||||
twig:
|
twig:
|
||||||
|
debug: true
|
||||||
|
auto_reload: true
|
||||||
enable_debug_extension: true
|
enable_debug_extension: true
|
||||||
|
|
|
@ -34,6 +34,8 @@ class container_configuration implements ConfigurationInterface
|
||||||
->arrayNode('twig')
|
->arrayNode('twig')
|
||||||
->addDefaultsIfNotSet()
|
->addDefaultsIfNotSet()
|
||||||
->children()
|
->children()
|
||||||
|
->booleanNode('debug')->defaultValue(null)->end()
|
||||||
|
->booleanNode('auto_reload')->defaultValue(null)->end()
|
||||||
->booleanNode('enable_debug_extension')->defaultValue(false)->end()
|
->booleanNode('enable_debug_extension')->defaultValue(false)->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
|
|
@ -69,6 +69,20 @@ class core extends Extension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the Twig options if defined in the environment
|
||||||
|
$definition = $container->getDefinition('template.twig.environment');
|
||||||
|
$twig_environment_options = $definition->getArgument(6);
|
||||||
|
if ($config['twig']['debug'])
|
||||||
|
{
|
||||||
|
$twig_environment_options['debug'] = true;
|
||||||
|
}
|
||||||
|
if ($config['twig']['auto_reload'])
|
||||||
|
{
|
||||||
|
$twig_environment_options['auto_reload'] = true;
|
||||||
|
}
|
||||||
|
// Replace the 6th argument, the options passed to the environment
|
||||||
|
$definition->replaceArgument(6, $twig_environment_options);
|
||||||
|
|
||||||
if ($config['twig']['enable_debug_extension'])
|
if ($config['twig']['enable_debug_extension'])
|
||||||
{
|
{
|
||||||
$definition = $container->getDefinition('template.twig.extensions.debug');
|
$definition = $container->getDefinition('template.twig.extensions.debug');
|
||||||
|
|
|
@ -60,7 +60,7 @@ class environment extends \Twig_Environment
|
||||||
|
|
||||||
$options = array_merge(array(
|
$options = array_merge(array(
|
||||||
'cache' => (defined('IN_INSTALL')) ? false : $cache_path,
|
'cache' => (defined('IN_INSTALL')) ? false : $cache_path,
|
||||||
'debug' => defined('DEBUG'),
|
'debug' => false,
|
||||||
'auto_reload' => (bool) $this->phpbb_config['load_tplcompile'],
|
'auto_reload' => (bool) $this->phpbb_config['load_tplcompile'],
|
||||||
'autoescape' => false,
|
'autoescape' => false,
|
||||||
), $options);
|
), $options);
|
||||||
|
|
|
@ -12,3 +12,14 @@ services:
|
||||||
|
|
||||||
dispatcher:
|
dispatcher:
|
||||||
class: phpbb\db\driver\container_mock
|
class: phpbb\db\driver\container_mock
|
||||||
|
|
||||||
|
template.twig.environment:
|
||||||
|
class: Exception
|
||||||
|
arguments:
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- []
|
||||||
|
|
|
@ -12,3 +12,14 @@ services:
|
||||||
|
|
||||||
dispatcher:
|
dispatcher:
|
||||||
class: phpbb\db\driver\container_mock
|
class: phpbb\db\driver\container_mock
|
||||||
|
|
||||||
|
template.twig.environment:
|
||||||
|
class: Exception
|
||||||
|
arguments:
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- ~
|
||||||
|
- []
|
||||||
|
|
Loading…
Add table
Reference in a new issue