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

VisitorFactory.php « Live « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cb64bff968ef6c6ea13e53a09f15de742189a5b7 (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
47
48
49
<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */
namespace Piwik\Plugins\Live;

use Exception;
use Piwik\Piwik;

class VisitorFactory
{
    /**
     * Returns Visitor object.
     * This method can be overwritten to use a different Visitor object
     *
     * @param array $visitorRawData
     * @throws \Exception
     * @return \Piwik\Plugins\Live\VisitorInterface
     * @ignore
     */
    public function create(array $visitorRawData = array())
    {
        $visitor = null;

        /**
         * Triggered while visit is filtering in live plugin. Subscribers to this
         * event can force the use of a custom visitor object that extends from
         * {@link Piwik\Plugins\Live\VisitorInterface}.
         *
         * @param \Piwik\Plugins\Live\VisitorInterface &$visitor Initialized to null, but can be set to
         *                                              a new visitor object. If it isn't modified
         *                                              Piwik uses the default class.
         * @param array $visitorRawData Raw data using in Visitor object constructor.
         */
        Piwik::postEvent('Live.makeNewVisitorObject', array(&$visitor, $visitorRawData));

        if (is_null($visitor)) {
            $visitor = new Visitor($visitorRawData);
        } elseif (!($visitor instanceof VisitorInterface)) {
            throw new Exception("The Visitor object set in the plugin must implement VisitorInterface");
        }

        return $visitor;
    }
}