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

Tasks.php « AutoLogImporter « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd8c0cdd66407befe42eb2571a85e3260cbef25e (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
<?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\AutoLogImporter;

use Piwik\Container\StaticContainer;
use Piwik\Settings\Setting;

class Tasks extends \Piwik\Plugin\Tasks
{
    public function schedule()
    {
        $this->hourly('importLogFiles');
    }

    public function importLogFiles()
    {
        $settings = StaticContainer::get('Piwik\Plugins\AutoLogImporter\Settings');

        if (!$settings->enabled->getValue()) {
            return;
        }

        // we validate to make sure directory is still readable etc, if not an exception will be thrown
        $this->validateSetting($settings->logFilesPath);

        $importer = StaticContainer::get('Piwik\Plugins\AutoLogImporter\LogImporter');
        $importer->importFiles();
    }

    private function validateSetting(Setting $setting)
    {
        if (isset($setting->validate)) {
            call_user_func($setting->validate, $setting->getValue(), $setting);
        }
    }
}