Skip to content

Commit

Permalink
Add state resetting at the end of the request (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnna authored and xyNNN committed Aug 30, 2018
1 parent b04828c commit 97fda55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
public: true
class: Xynnn\GoogleTagManagerBundle\Service\GoogleTagManager
factory: ["@google_tag_manager.factory", create]
tags:
- { name: "kernel.reset", method: "reset" }

templating.helper.google_tag_manager:
public: false
Expand Down
9 changes: 9 additions & 0 deletions Service/GoogleTagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,13 @@ public function hasData()
return is_array($this->getData())
&& count($this->getData()) > 0;
}

/**
* Reset internal state at the end of the request
*/
public function reset()
{
$this->data = array();
$this->push = array();
}
}

0 comments on commit 97fda55

Please sign in to comment.