Merge branch '3.2.x'

This commit is contained in:
Marc Alexander 2017-04-16 19:41:19 +02:00
commit 465ceab1e6
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
12 changed files with 49 additions and 5 deletions

View file

@ -11,6 +11,7 @@ services:
- '%core.template.cache_path%' - '%core.template.cache_path%'
- '@ext.manager' - '@ext.manager'
- '@template.twig.loader' - '@template.twig.loader'
- '@dispatcher'
- [] - []
calls: calls:
- [setLexer, ['@template.twig.lexer']] - [setLexer, ['@template.twig.lexer']]

View file

@ -84,6 +84,7 @@ services:
- '%core.template.cache_path%' - '%core.template.cache_path%'
- null - null
- '@template.twig.loader' - '@template.twig.loader'
- null
- [] - []
calls: calls:
- [setLexer, ['@template.twig.lexer']] - [setLexer, ['@template.twig.lexer']]

View file

@ -656,7 +656,7 @@ class messenger
*/ */
protected function setup_template() protected function setup_template()
{ {
global $phpbb_container; global $phpbb_container, $phpbb_dispatcher;
if ($this->template instanceof \phpbb\template\template) if ($this->template instanceof \phpbb\template\template)
{ {
@ -671,7 +671,9 @@ class messenger
$phpbb_container->get('ext.manager'), $phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader( new \phpbb\template\twig\loader(
$phpbb_container->get('filesystem') $phpbb_container->get('filesystem')
) ),
$phpbb_dispatcher,
array()
); );
$template_environment->setLexer($phpbb_container->get('template.twig.lexer')); $template_environment->setLexer($phpbb_container->get('template.twig.lexer'));

View file

@ -32,6 +32,9 @@ class environment extends \Twig_Environment
/** @var \phpbb\extension\manager */ /** @var \phpbb\extension\manager */
protected $extension_manager; protected $extension_manager;
/** @var \phpbb\event\dispatcher_interface */
protected $phpbb_dispatcher;
/** @var string */ /** @var string */
protected $phpbb_root_path; protected $phpbb_root_path;
@ -53,15 +56,17 @@ class environment extends \Twig_Environment
* @param string $cache_path The path to the cache directory * @param string $cache_path The path to the cache directory
* @param \phpbb\extension\manager $extension_manager phpBB extension manager * @param \phpbb\extension\manager $extension_manager phpBB extension manager
* @param \Twig_LoaderInterface $loader Twig loader interface * @param \Twig_LoaderInterface $loader Twig loader interface
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object
* @param array $options Array of options to pass to Twig * @param array $options Array of options to pass to Twig
*/ */
public function __construct(\phpbb\config\config $phpbb_config, \phpbb\filesystem\filesystem $filesystem, \phpbb\path_helper $path_helper, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array()) public function __construct(\phpbb\config\config $phpbb_config, \phpbb\filesystem\filesystem $filesystem, \phpbb\path_helper $path_helper, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, \phpbb\event\dispatcher_interface $phpbb_dispatcher = null, $options = array())
{ {
$this->phpbb_config = $phpbb_config; $this->phpbb_config = $phpbb_config;
$this->filesystem = $filesystem; $this->filesystem = $filesystem;
$this->phpbb_path_helper = $path_helper; $this->phpbb_path_helper = $path_helper;
$this->extension_manager = $extension_manager; $this->extension_manager = $extension_manager;
$this->phpbb_dispatcher = $phpbb_dispatcher;
$this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path(); $this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path();
$this->web_root_path = $this->phpbb_path_helper->get_web_root_path(); $this->web_root_path = $this->phpbb_path_helper->get_web_root_path();
@ -202,8 +207,37 @@ class environment extends \Twig_Environment
$context['definition']->set('STYLESHEETS', '__STYLESHEETS_' . $placeholder_salt . '__'); $context['definition']->set('STYLESHEETS', '__STYLESHEETS_' . $placeholder_salt . '__');
} }
/**
* Allow changing the template output stream before rendering
*
* @event core.twig_environment_render_template_before
* @var array context Array with template variables
* @var string name The template name
* @since 3.2.1-RC1
*/
if ($this->phpbb_dispatcher)
{
$vars = array('context', 'name');
extract($this->phpbb_dispatcher->trigger_event('core.twig_environment_render_template_before', compact($vars)));
}
$output = parent::render($name, $context); $output = parent::render($name, $context);
/**
* Allow changing the template output stream after rendering
*
* @event core.twig_environment_render_template_after
* @var array context Array with template variables
* @var string name The template name
* @var string output Rendered template output stream
* @since 3.2.1-RC1
*/
if ($this->phpbb_dispatcher)
{
$vars = array('context', 'name', 'output');
extract($this->phpbb_dispatcher->trigger_event('core.twig_environment_render_template_after', compact($vars)));
}
return $this->inject_assets($output, $placeholder_salt); return $this->inject_assets($output, $placeholder_salt);
} }

View file

@ -114,6 +114,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$cache_path, $cache_path,
null, null,
$loader, $loader,
new \phpbb\event\dispatcher($container),
array( array(
'cache' => false, 'cache' => false,
'debug' => false, 'debug' => false,

View file

@ -81,6 +81,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$cache_path, $cache_path,
null, null,
new \phpbb\template\twig\loader($filesystem, ''), new \phpbb\template\twig\loader($filesystem, ''),
new \phpbb\event\dispatcher($phpbb_container),
array( array(
'cache' => false, 'cache' => false,
'debug' => false, 'debug' => false,

View file

@ -70,6 +70,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$cache_path, $cache_path,
null, null,
$loader, $loader,
new \phpbb\event\dispatcher($container),
array( array(
'cache' => false, 'cache' => false,
'debug' => false, 'debug' => false,
@ -78,8 +79,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
) )
); );
$container = new phpbb_mock_container_builder();
$this->migrator = new \phpbb\db\migrator( $this->migrator = new \phpbb\db\migrator(
$container, $container,
$this->config, $this->config,

View file

@ -67,6 +67,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
$cache_path, $cache_path,
$this->extension_manager, $this->extension_manager,
$loader, $loader,
new \phpbb\event\dispatcher($container),
array( array(
'cache' => false, 'cache' => false,
'debug' => false, 'debug' => false,

View file

@ -161,6 +161,7 @@ Zeta test event in all',
$cache_path, $cache_path,
$this->extension_manager, $this->extension_manager,
$loader, $loader,
new \phpbb\event\dispatcher($container),
array( array(
'cache' => false, 'cache' => false,
'debug' => false, 'debug' => false,

View file

@ -53,6 +53,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$cache_path, $cache_path,
null, null,
$loader, $loader,
new \phpbb\event\dispatcher($container),
array( array(
'cache' => false, 'cache' => false,
'debug' => false, 'debug' => false,

View file

@ -105,6 +105,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$cache_path, $cache_path,
null, null,
$loader, $loader,
new \phpbb\event\dispatcher($container),
array( array(
'cache' => false, 'cache' => false,
'debug' => false, 'debug' => false,

View file

@ -48,6 +48,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$cache_path, $cache_path,
null, null,
$loader, $loader,
new \phpbb\event\dispatcher($container),
array( array(
'cache' => false, 'cache' => false,
'debug' => false, 'debug' => false,