aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/template
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2017-01-11 22:50:50 +0700
committerrxu <rxu@mail.ru>2017-04-16 22:43:49 +0700
commit633bbc9c6d42785233ea10165a081c7c32795d1c (patch)
tree9c91484ebfbb96e823e0c00e8259774571631595 /phpBB/phpbb/template
parentc5126af1df58229cfc30eb8cd81c311a307747cd (diff)
downloadforums-633bbc9c6d42785233ea10165a081c7c32795d1c.tar
forums-633bbc9c6d42785233ea10165a081c7c32795d1c.tar.gz
forums-633bbc9c6d42785233ea10165a081c7c32795d1c.tar.bz2
forums-633bbc9c6d42785233ea10165a081c7c32795d1c.tar.xz
forums-633bbc9c6d42785233ea10165a081c7c32795d1c.zip
[ticket/14990] Add core events to the Twig environment
PHPBB3-14990
Diffstat (limited to 'phpBB/phpbb/template')
-rw-r--r--phpBB/phpbb/template/twig/environment.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php
index 179412a2e3..b2b4f990dd 100644
--- a/phpBB/phpbb/template/twig/environment.php
+++ b/phpBB/phpbb/template/twig/environment.php
@@ -32,6 +32,11 @@ class environment extends \Twig_Environment
/** @var \phpbb\extension\manager */
protected $extension_manager;
+ /**
+ * @var \phpbb\event\dispatcher_interface
+ */
+ protected $phpbb_dispatcher;
+
/** @var string */
protected $phpbb_root_path;
@@ -54,14 +59,16 @@ class environment extends \Twig_Environment
* @param \phpbb\extension\manager $extension_manager phpBB extension manager
* @param \Twig_LoaderInterface $loader Twig loader interface
* @param array $options Array of options to pass to Twig
+ * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object
*/
- 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, $options = array(), \phpbb\event\dispatcher_interface $phpbb_dispatcher = null)
{
$this->phpbb_config = $phpbb_config;
$this->filesystem = $filesystem;
$this->phpbb_path_helper = $path_helper;
$this->extension_manager = $extension_manager;
+ $this->phpbb_dispatcher = $phpbb_dispatcher;
$this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path();
$this->web_root_path = $this->phpbb_path_helper->get_web_root_path();
@@ -202,8 +209,31 @@ class environment extends \Twig_Environment
$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
+ */
+ $vars = array('context', 'name');
+ extract($this->phpbb_dispatcher->trigger_event('core.twig_environment_render_template_before', compact($vars)));
+
$output = parent::render($name, $context);
+ /**
+ * Allow changing the template output stream after rendering
+ *
+ * @event core.twig_environment_render_template_before
+ * @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
+ */
+ $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);
}