Commit 90c7aad7 authored by Avris's avatar Avris

v4.0

parent c69c5b78
googleAnalytics:
class: Avris\Micrus\GoogleAnalytics\GoogleAnalytics
params: ['@config.parameters.?googleAnalytics']
events: ['terminate']
......@@ -2,10 +2,11 @@
namespace Avris\Micrus\GoogleAnalytics;
use Avris\Bag\Bag;
use Avris\Micrus\Bootstrap\EventSubscriberInterface;
use Avris\Micrus\Controller\Http\RequestInterface;
use Avris\Micrus\Tool\Config\ParametersProvider;
class GoogleAnalytics extends \Twig_Extension implements ParametersProvider
class GoogleAnalytics extends \Twig_Extension implements ParametersProvider, EventSubscriberInterface
{
const CODE = <<<HTML
<script>
......@@ -101,10 +102,12 @@ HTML;
curl_close($ch);
}
public function onTerminate()
public function getSubscribedEvents(): iterable
{
foreach ($this->queue as $options) {
$this->sendReport($options);
}
yield 'terminate' => function () {
foreach ($this->queue as $options) {
$this->sendReport($options);
}
};
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment