From 456c45693eeb2df33edc495f61bc91ea5f06eada Mon Sep 17 00:00:00 2001 From: Thomas Steur <tsteur@users.noreply.github.com> Date: Fri, 19 May 2017 03:22:43 +0000 Subject: [PATCH] make TrackerUpdater a public API --- plugins/CustomPiwikJs/TrackerUpdater.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/CustomPiwikJs/TrackerUpdater.php b/plugins/CustomPiwikJs/TrackerUpdater.php index d90d8c166d..a6fadbda47 100644 --- a/plugins/CustomPiwikJs/TrackerUpdater.php +++ b/plugins/CustomPiwikJs/TrackerUpdater.php @@ -12,7 +12,10 @@ use Piwik\Plugins\CustomPiwikJs\TrackingCode\PiwikJsManipulator; use Piwik\Plugins\CustomPiwikJs\TrackingCode\PluginTrackerFiles; /** - * Updates the Javascript file containing the Tracker. + * Updates the Piwik JavaScript Tracker "piwik.js" in case plugins extend the tracker. + * + * Usage: + * StaticContainer::get('Piwik\Plugins\CustomPiwikJs\TrackerUpdater')->update(); */ class TrackerUpdater { @@ -56,6 +59,12 @@ class TrackerUpdater $this->trackerFiles = $trackerFiles; } + /** + * Checks whether the Piwik JavaScript tracker file "piwik.js" is writable. + * @throws \Exception In case the piwik.js file is not writable. + * + * @api + */ public function checkWillSucceed() { $this->fromFile->checkReadable(); @@ -75,6 +84,15 @@ class TrackerUpdater return $newContent; } + /** + * Updates / re-generates the Piwik JavaScript tracker "piwik.js". + * + * It may not be possible to update the "piwik.js" tracker file if the file is not writable. It won't throw + * an exception in such a case and instead just to nothing. To check if the update would succeed, call + * {@link checkWillSucceed()}. + * + * @api + */ public function update() { if (!$this->toFile->hasWriteAccess() || !$this->fromFile->hasReadAccess()) { -- GitLab