Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Tasks.php « FileSynchronizer « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b269ef691cfc0059f79123f62fa97ba853d6b258 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
        }
    }
}