diff options
Diffstat (limited to 'plugins/FileSynchronizer/Tasks.php')
-rw-r--r-- | plugins/FileSynchronizer/Tasks.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/FileSynchronizer/Tasks.php b/plugins/FileSynchronizer/Tasks.php new file mode 100644 index 0000000000..b269ef691c --- /dev/null +++ b/plugins/FileSynchronizer/Tasks.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright (C) Piwik PRO - All rights reserved. + * + * Using this code requires that you first get a license from Piwik PRO. + * Unauthorized copying of this file, via any medium is strictly prohibited. + * + * @link http://piwik.pro + */ + +namespace Piwik\Plugins\FileSynchronizer; + +use Piwik\Container\StaticContainer; +use Piwik\Settings\Setting; + +class Tasks extends \Piwik\Plugin\Tasks +{ + public function schedule() + { + $this->hourly('syncFiles'); + } + + public function syncFiles() + { + $settings = StaticContainer::get('Piwik\Plugins\FileSynchronizer\Settings'); + + if (!$settings->enabled->getValue()) { + return; + } + + // we validate to make sure it is still readable etc. + $this->validateSetting($settings->copyCommandTemplate); + $this->validateSetting($settings->sourceDirectory); + $this->validateSetting($settings->targetDirectory); + + $sync = StaticContainer::get('Piwik\Plugins\FileSynchronizer\SyncFiles'); + $sync->sync(); + } + + private function validateSetting(Setting $setting) + { + if (isset($setting->validate)) { + call_user_func($setting->validate, $setting->getValue(), $setting); + } + } +} |