Skip to content
Extraits de code Groupes Projets
Valider 456c4569 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

make TrackerUpdater a public API

parent 33d0ae18
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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()) {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter