diff options
author | sgiehl <stefan@piwik.org> | 2016-09-15 00:19:06 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2016-09-15 00:19:06 +0300 |
commit | 56875fe873a2447b615dca8d03c1a84ea4a6d81b (patch) | |
tree | a7eeaa0ac3ff4ff5603da705a1aabf83ea656011 /core/Updater.php | |
parent | 7a2f3c50deea250643e0a8fef3ee6afd9e09ece9 (diff) |
backported #10468 to 2.x
Diffstat (limited to 'core/Updater.php')
-rw-r--r-- | core/Updater.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/Updater.php b/core/Updater.php index 90c8c6839c..00cba745b2 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -272,6 +272,35 @@ class Updater $this->executeListenerHook('onComponentUpdateFinished', array($componentName, $updatedVersion, $warningMessages)); + /** + * Event triggered after a component has been updated. + * + * Can be used to handle stuff that should be done after a component was updated + * + * **Example** + * + * Piwik::addAction('Updater.componentUpdated', function ($componentName, $updatedVersion, $warningMessages) { + * $mail = new Mail(); + * $mail->setDefaultFromPiwik(); + * $mail->addTo('test@example.org'); + * $mail->setSubject('Component was updated); + * $message = sprintf( + * 'Component %1$s has been updated to version %2$s', + * $componentName, $updatedVersion + * ); + * if (!empty($warningMessages)) { + * $message .= "Some warnings occured:\n" . implode("\n", $warningMessages); + * } + * $mail->setBodyText($message); + * $mail->send(); + * }); + * + * @param string $componentName 'core', or plugin name + * @param string $updatedVersion version updated to + * @param array $warningMessages warnings occurred during update + */ + Piwik::postEvent('Updater.componentUpdated', array($componentName, $updatedVersion, $warningMessages)); + return $warningMessages; } |