Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2014-03-14 13:05:12 +0400
committermattab <matthieu.aubry@gmail.com>2014-03-14 13:05:12 +0400
commitc22a0017beb391ed9734b67abf5b1bcfeb26d233 (patch)
treecdd2f0a3a18a4c83764b8a10abc7d74b2c830acc /core/Twig.php
parentf2466a580bcc1a33fb8ccee420bcf31ceb7b00ed (diff)
Allow templates postEvent() calls to also pass parameters. For example this is done in the twig template:
``` {{ postEvent("Template.jsGlobalVariables", minDateYear, maxDateYear) }} ``` and you can hook on this event, by doing: ``` public function addTrackingHostnamesToJs(&$out, $minDateYear, $maxDateYear) { // printout out the data as a comment for testing $out .= "/* " . $minDateYear . " - " . $maxDateYear . " */"; ```
Diffstat (limited to 'core/Twig.php')
-rw-r--r--core/Twig.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/Twig.php b/core/Twig.php
index 4da7a364f8..16348e524c 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -118,8 +118,17 @@ class Twig
protected function addFunction_postEvent()
{
$postEventFunction = new Twig_SimpleFunction('postEvent', function ($eventName) {
+ // get parameters to twig function
+ $params = func_get_args();
+ // remove the first value (event name)
+ array_shift($params);
+
+ // make the first value the string that will get output in the template
+ // plugins can modify this string
$str = '';
- Piwik::postEvent($eventName, array(&$str));
+ $params = array_merge( array( &$str ), $params);
+
+ Piwik::postEvent($eventName, $params);
return $str;
}, array('is_safe' => array('html')));
$this->twig->addFunction($postEventFunction);